Removed some useless code, codestyle changes and removed an index

This commit is contained in:
Gabriel Mazetto 2017-08-09 08:41:32 +02:00
parent 95a270c871
commit fff5ebdcae
6 changed files with 7 additions and 12 deletions

View file

@ -1432,9 +1432,7 @@ class Project < ActiveRecord::Base
def storage
@storage ||=
if !has_attribute?(:storage_version) # during migration
Storage::LegacyProject.new(self)
elsif self.storage_version && self.storage_version >= 1
if self.storage_version && self.storage_version >= 1
Storage::HashedProject.new(self)
else
Storage::LegacyProject.new(self)
@ -1442,7 +1440,7 @@ class Project < ActiveRecord::Base
end
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
end
end

View file

@ -11,14 +11,14 @@ module Storage
#
# @return [String] directory where repository is stored
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
# 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(#{base_dir}/#{disk_hash})
"#{base_dir}/#{disk_hash}"
end
def ensure_storage_path_exist

View file

@ -499,7 +499,7 @@
= f.check_box :hashed_storage_enabled
Create new projects using hashed storage paths
.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.
%em (EXPERIMENTAL)
.form-group

View file

@ -5,11 +5,9 @@ class AddStorageFieldsToProject < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_column :projects, :storage_version, :integer, limit: 2
add_concurrent_index :projects, :storage_version
end
def down

View file

@ -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", ["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", ["storage_version"], name: "index_projects_on_storage_version", 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|

View file

@ -2389,7 +2389,7 @@ describe Project do
subject { project.rename_repo }
it { expect{subject}.to raise_error(StandardError) }
it { expect { subject }.to raise_error(StandardError) }
end
end
end
@ -2469,7 +2469,7 @@ describe Project do
subject { project.rename_repo }
it { expect{subject}.to raise_error(StandardError) }
it { expect { subject }.to raise_error(StandardError) }
end
end
end