Commit fff5ebdc authored by Gabriel Mazetto's avatar Gabriel Mazetto

Removed some useless code, codestyle changes and removed an index

parent 95a270c8
...@@ -1432,9 +1432,7 @@ class Project < ActiveRecord::Base ...@@ -1432,9 +1432,7 @@ class Project < ActiveRecord::Base
def storage def storage
@storage ||= @storage ||=
if !has_attribute?(:storage_version) # during migration if self.storage_version && self.storage_version >= 1
Storage::LegacyProject.new(self)
elsif self.storage_version && self.storage_version >= 1
Storage::HashedProject.new(self) Storage::HashedProject.new(self)
else else
Storage::LegacyProject.new(self) Storage::LegacyProject.new(self)
...@@ -1442,7 +1440,7 @@ class Project < ActiveRecord::Base ...@@ -1442,7 +1440,7 @@ class Project < ActiveRecord::Base
end end
def use_hashed_storage def use_hashed_storage
if !self.persisted? && current_application_settings.hashed_storage_enabled if self.new_record? && current_application_settings.hashed_storage_enabled
self.storage_version = LATEST_STORAGE_VERSION self.storage_version = LATEST_STORAGE_VERSION
end end
end end
......
...@@ -11,14 +11,14 @@ module Storage ...@@ -11,14 +11,14 @@ module Storage
# #
# @return [String] directory where repository is stored # @return [String] directory where repository is stored
def base_dir def base_dir
%Q(#{disk_hash[0..1]}/#{disk_hash[2..3]}) if disk_hash "#{disk_hash[0..1]}/#{disk_hash[2..3]}" if disk_hash
end end
# Disk path is used to build repository and project's wiki path on disk # 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 # @return [String] combination of base_dir and the repository own name without `.git` or `.wiki.git` extensions
def disk_path def disk_path
%Q(#{base_dir}/#{disk_hash}) "#{base_dir}/#{disk_hash}"
end end
def ensure_storage_path_exist def ensure_storage_path_exist
......
...@@ -499,7 +499,7 @@ ...@@ -499,7 +499,7 @@
= f.check_box :hashed_storage_enabled = f.check_box :hashed_storage_enabled
Create new projects using hashed storage paths Create new projects using hashed storage paths
.help-block .help-block
Enable immutable, hash based paths and repository names to store repositories on disk. This prevents Enable immutable, hash-based paths and repository names to store repositories on disk. This prevents
repositories from having to be moved or renamed when the Project URL changes and may improve disk I/O performance. repositories from having to be moved or renamed when the Project URL changes and may improve disk I/O performance.
%em (EXPERIMENTAL) %em (EXPERIMENTAL)
.form-group .form-group
......
...@@ -5,11 +5,9 @@ class AddStorageFieldsToProject < ActiveRecord::Migration ...@@ -5,11 +5,9 @@ class AddStorageFieldsToProject < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
disable_ddl_transaction!
def up def up
add_column :projects, :storage_version, :integer, limit: 2 add_column :projects, :storage_version, :integer, limit: 2
add_concurrent_index :projects, :storage_version
end end
def down def down
......
...@@ -1226,7 +1226,6 @@ ActiveRecord::Schema.define(version: 20170820100558) do ...@@ -1226,7 +1226,6 @@ ActiveRecord::Schema.define(version: 20170820100558) do
add_index "projects", ["pending_delete"], name: "index_projects_on_pending_delete", using: :btree add_index "projects", ["pending_delete"], name: "index_projects_on_pending_delete", using: :btree
add_index "projects", ["runners_token"], name: "index_projects_on_runners_token", using: :btree add_index "projects", ["runners_token"], name: "index_projects_on_runners_token", using: :btree
add_index "projects", ["star_count"], name: "index_projects_on_star_count", using: :btree add_index "projects", ["star_count"], name: "index_projects_on_star_count", using: :btree
add_index "projects", ["storage_version"], name: "index_projects_on_storage_version", using: :btree
add_index "projects", ["visibility_level"], name: "index_projects_on_visibility_level", using: :btree add_index "projects", ["visibility_level"], name: "index_projects_on_visibility_level", using: :btree
create_table "protected_branch_merge_access_levels", force: :cascade do |t| create_table "protected_branch_merge_access_levels", force: :cascade do |t|
......
...@@ -2389,7 +2389,7 @@ describe Project do ...@@ -2389,7 +2389,7 @@ describe Project do
subject { project.rename_repo } subject { project.rename_repo }
it { expect{subject}.to raise_error(StandardError) } it { expect { subject }.to raise_error(StandardError) }
end end
end end
end end
...@@ -2469,7 +2469,7 @@ describe Project do ...@@ -2469,7 +2469,7 @@ describe Project do
subject { project.rename_repo } subject { project.rename_repo }
it { expect{subject}.to raise_error(StandardError) } it { expect { subject }.to raise_error(StandardError) }
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment