Refuse to delete a repository in OpenProject on FS permission errors

This commit changes the behavior of removing repositories.
It is no longer possible to remove a managed repository (model) when the
underlying repository directory could not be removed.

This error originally occurred when Apache committed changes to the repository
through mod_svn, which resulted in the OpenProject user being unable to
delete a particular subdirectory.
pull/3428/head
Oliver Günther 9 years ago
parent fc2e904aca
commit 6661f2b6d5
  1. 8
      app/controllers/repositories_controller.rb
  2. 10
      app/models/repository.rb
  3. 4
      app/services/scm/delete_managed_repository_service.rb
  4. 3
      config/locales/en.yml

@ -109,8 +109,12 @@ class RepositoriesController < ApplicationController
end
def destroy
@project.repository.destroy
flash[:notice] = I18n.t('repositories.delete_sucessful')
repository = @project.repository
if repository.destroy
flash[:notice] = I18n.t('repositories.delete_sucessful')
else
flash[:error] = repository.errors.full_messages.join("\n")
end
redirect_to settings_repository_tab_path
end

@ -432,8 +432,12 @@ class Repository < ActiveRecord::Base
service = Scm::DeleteManagedRepositoryService.new(self)
# Even if the service can't remove the physical repository,
# we should continue removing the associated instance.
service.call
true
if service.call
true
else
errors.add(:base, I18n.t('repositories.errors.filesystem_access_failed',
message: I18n.t('repositories.errors.deletion_failed')))
raise ActiveRecord::Rollback
end
end
end

@ -60,8 +60,8 @@ Scm::DeleteManagedRepositoryService = Struct.new :repository do
true
rescue SystemCallError => e
Rails.logger.error("An error occurred while accessing the repository '#{repository.root_url}' \
on filesystem: #{e.message}")
Rails.logger.error("An error occurred while accessing the repository '#{repository.root_url}'" +
"on filesystem: #{e.message}")
false
end
end

@ -1317,7 +1317,8 @@ en:
build_failed: "Unable to create the repository with the selected configuration. %{reason}"
empty_repository: "The repository exists, but is empty. It does not contain any revisions yet."
exists_on_filesystem: "The repository directory exists already on filesystem."
filesystem_access_failed: "An error occurred while accessing the repository on filesystem: %{message}."
filesystem_access_failed: "An error occurred while accessing the repository on filesystem: %{message}"
deletion_failed: "The repository could not be deleted on disk due to lacking permissions. Please contact your administrator to resolve this issue."
not_manageable: "This repository vendor cannot be managed by OpenProject."
path_permission_failed: "An error occurred trying to create the following path: %{path}. Please ensure that OpenProject may write to that folder."
unauthorized: "You're not authorized to access the repository or the credentials are invalid."

Loading…
Cancel
Save