files_controller.rb revision 9a85fb6390203b5e202dcc2a9d7e10ad3896096d
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync helper_method :repository, :ref, :oid, :path, :branch_name
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync before_filter :check_write_permissions, only: [:new, :create, :update]
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync raise Repository::FileNotFoundError, path if @info.nil?
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync elsif request.format == 'text/html' || @info[:type] != :file
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync case @info[:type]
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync where(basepath: File.basepath(@info[:entry][:path])).
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync page = @page = params[:page].nil? ? 1 : params[:page].to_i
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @current_file = repository.read_file(path, oid) if path && !repository.dir?(path)
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @commits = repository.commits(start_oid: oid, path: path, offset: offset, limit: @per_page)
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync repository.save_file @file.file.path, @file.filepath, @file.message, current_user
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync flash[:success] = "Successfully saved the uploaded file."
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if ontology = repository.ontologies.find_by_file(@file.filepath)
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync redirect_to edit_repository_ontology_path(repository, ontology)
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync redirect_to fancy_repository_path(repository, path: @file.filepath)
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync repository.save_file @file_changed.file.path, @file_changed.filepath, @file_changed.message, current_user
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync redirect_to fancy_repository_path(repository, path: @file_changed.filepath)
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @repository ||= Repository.find_by_path!(params[:repository_id])
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync args = params[:upload_file].merge({repository: repository}) unless params[:upload_file].nil?
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync filepath = Rails.root.join('tmp', 'files', oid, "#{Time.now.nsec}_#{params[:path].split('/')[-1]}")
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync target_directory: params[:path].split('/')[0..-2].join('/'),
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync render text: repository.read_file(path, oid)[:content],
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync content_type: Mime::Type.lookup('application/force-download')