From 008a6a6ce6fa943adcfecf3a606b845cfa282680 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Wed, 14 Mar 2018 14:42:49 +0100 Subject: Route path lookups through legacy_disk_path --- config/initializers/1_settings.rb | 9 ++------- config/initializers/6_validations.rb | 6 +++--- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'config') diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index ea0dee7af53..53cf0010d8e 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -467,12 +467,7 @@ unless Settings.repositories.storages['default'] end Settings.repositories.storages.each do |key, storage| - storage = Settingslogic.new(storage) - - # Expand relative paths - storage['path'] = Settings.absolute(storage['path']) - - Settings.repositories.storages[key] = storage + Settings.repositories.storages[key] = Gitlab::GitalyClient::StorageSettings.new(storage) end # @@ -486,7 +481,7 @@ repositories_storages = Settings.repositories.storages.values repository_downloads_path = Settings.gitlab['repository_downloads_path'].to_s.gsub(%r{/$}, '') repository_downloads_full_path = File.expand_path(repository_downloads_path, Settings.gitlab['user_home']) -if repository_downloads_path.blank? || repositories_storages.any? { |rs| [repository_downloads_path, repository_downloads_full_path].include?(rs['path'].gsub(%r{/$}, '')) } +if repository_downloads_path.blank? || repositories_storages.any? { |rs| [repository_downloads_path, repository_downloads_full_path].include?(rs.legacy_disk_path.gsub(%r{/$}, '')) } Settings.gitlab['repository_downloads_path'] = File.join(Settings.shared['path'], 'cache/archive') end diff --git a/config/initializers/6_validations.rb b/config/initializers/6_validations.rb index f8e67ce04c9..d92cdb97766 100644 --- a/config/initializers/6_validations.rb +++ b/config/initializers/6_validations.rb @@ -5,7 +5,7 @@ end def find_parent_path(name, path) parent = Pathname.new(path).realpath.parent Gitlab.config.repositories.storages.detect do |n, rs| - name != n && Pathname.new(rs['path']).realpath == parent + name != n && Pathname.new(rs.legacy_disk_path).realpath == parent end rescue Errno::EIO, Errno::ENOENT => e warning = "WARNING: couldn't verify #{path} (#{name}). "\ @@ -33,7 +33,7 @@ def validate_storages_config "If you're using the Gitlab Development Kit, you can update your configuration running `gdk reconfigure`.\n" end - if !repository_storage.is_a?(Hash) || repository_storage['path'].nil? + if !repository_storage.is_a?(Gitlab::GitalyClient::StorageSettings) || repository_storage.legacy_disk_path.nil? storage_validation_error("#{name} is not a valid storage, because it has no `path` key. Refer to gitlab.yml.example for an updated example") end @@ -50,7 +50,7 @@ end def validate_storages_paths Gitlab.config.repositories.storages.each do |name, repository_storage| - parent_name, _parent_path = find_parent_path(name, repository_storage['path']) + parent_name, _parent_path = find_parent_path(name, repository_storage.legacy_disk_path) if parent_name storage_validation_error("#{name} is a nested path of #{parent_name}. Nested paths are not supported for repository storages") end -- cgit v1.2.3