files.rb revision f2c5529a09f91b3f5d46ac41d008159448b863c6
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster # virtual attribute for upload
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster before_create :commit_raw_file, unless: :commit_oid?
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster self.path = @raw_file.original_filename if self.path.nil?
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster # otherwise the file upload is broken (no implicit conversion of ActionDispatch::Http::UploadedFile into String):
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster tmp_file = if @raw_file.class == ActionDispatch::Http::UploadedFile
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster repository.save_file(tmp_file, self.path, "message", user)
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster Ontohub::Application.config.commits_path.join(commit_oid)
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster # path to the raw file
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster # path to the raw file, checks out the raw file if is missing
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster # path to xml file (hets output)
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster # path to xml file (hets output) with code positions
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster # checks out the raw file
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster File.open(raw_path, "w"){|f| f.write raw_data }
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster # returns the raw data directly from the repository