diff options
-rw-r--r-- | app/controllers/projects/blob_controller.rb | 10 | ||||
-rw-r--r-- | app/controllers/projects/tree_controller.rb | 9 |
2 files changed, 15 insertions, 4 deletions
diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index a1a8bed09f4..db3d173b98d 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -30,8 +30,12 @@ class Projects::BlobController < Projects::ApplicationController def blob @blob ||= @repository.blob_at(@commit.id, @path) - return not_found! unless @blob - - @blob + if @blob + @blob + elsif tree.entries.any? + redirect_to project_tree_path(@project, File.join(@ref, @path)) and return + else + return not_found! + end end end diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb index 30c94ec6da0..4d033b36848 100644 --- a/app/controllers/projects/tree_controller.rb +++ b/app/controllers/projects/tree_controller.rb @@ -1,7 +1,14 @@ # Controller for viewing a repository's file structure class Projects::TreeController < Projects::BaseTreeController def show - return not_found! if tree.entries.empty? + + if tree.entries.empty? + if @repository.blob_at(@commit.id, @path) + redirect_to project_blob_path(@project, File.join(@ref, @path)) and return + else + return not_found! + end + end respond_to do |format| format.html |