Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Mazetto <brodock@gmail.com>2017-08-04 08:30:42 +0300
committerGabriel Mazetto <brodock@gmail.com>2017-08-22 07:33:20 +0300
commit9e6fa996eab978506af1084b79a9c3f91f6d575b (patch)
tree39cdc0aafa13c16551f4f7f244a19e94d6b8582f /app/models/concerns/storage
parent53403399577bdca0e8f0886fa62ce0e75c14a8e0 (diff)
New storage is now "Hashed" instead of "UUID"
Diffstat (limited to 'app/models/concerns/storage')
-rw-r--r--app/models/concerns/storage/hashed_project.rb (renamed from app/models/concerns/storage/uuid_project.rb)24
-rw-r--r--app/models/concerns/storage/legacy_project.rb12
2 files changed, 30 insertions, 6 deletions
diff --git a/app/models/concerns/storage/uuid_project.rb b/app/models/concerns/storage/hashed_project.rb
index 8a73287e518..292a73903b5 100644
--- a/app/models/concerns/storage/uuid_project.rb
+++ b/app/models/concerns/storage/hashed_project.rb
@@ -1,17 +1,23 @@
module Storage
- module UUIDProject
+ module HashedProject
extend ActiveSupport::Concern
- def uuid_dir
- %Q(#{uuid[0..1]}/#{uuid[2..3]})
+ # Base directory
+ #
+ # @return [String] directory where repository is stored
+ def base_dir
+ %Q(#{disk_hash[0..1]}/#{disk_hash[2..3]}) if disk_hash
end
+ # Disk path is used to build repository and project's wiki path on disk
+ #
+ # @return [String] combination of base_dir and the repository own name without `.git` or `.wiki.git` extensions
def disk_path
- %Q(#{uuid_dir}/#{uuid})
+ %Q(#{base_dir}/#{disk_hash})
end
def ensure_storage_path_exist
- gitlab_shell.add_namespace(repository_storage_path, uuid_dir)
+ gitlab_shell.add_namespace(repository_storage_path, base_dir)
end
def rename_repo
@@ -54,5 +60,13 @@ module Storage
Gitlab::UploadsTransfer.new.rename_project(path_was, path, namespace.full_path)
Gitlab::PagesTransfer.new.rename_project(path_was, path, namespace.full_path)
end
+
+ private
+
+ # Generates the hash for the project path and name on disk
+ # If you need to refer to the repository on disk, use the `#disk_path`
+ def disk_hash
+ @disk_hash ||= Digest::SHA2.hexdigest(self.id.to_s) if self.id
+ end
end
end
diff --git a/app/models/concerns/storage/legacy_project.rb b/app/models/concerns/storage/legacy_project.rb
index c38042495f4..839bbcc76ea 100644
--- a/app/models/concerns/storage/legacy_project.rb
+++ b/app/models/concerns/storage/legacy_project.rb
@@ -2,12 +2,22 @@ module Storage
module LegacyProject
extend ActiveSupport::Concern
+ # Base directory
+ #
+ # @return [String] directory where repository is stored
+ def base_dir
+ namespace.full_path
+ end
+
+ # Disk path is used to build repository and project's wiki path on disk
+ #
+ # @return [String] combination of base_dir and the repository own name without `.git` or `.wiki.git` extensions
def disk_path
full_path
end
def ensure_storage_path_exist
- gitlab_shell.add_namespace(repository_storage_path, namespace.full_path)
+ gitlab_shell.add_namespace(repository_storage_path, base_dir)
end
def rename_repo