summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Mazetto <brodock@gmail.com>2017-08-09 08:41:32 +0200
committerGabriel Mazetto <brodock@gmail.com>2017-08-22 06:33:20 +0200
commitfff5ebdcae6794de35f8eaff15217d8643c83686 (patch)
tree178ffe67551e78ec99e5d2df001bbcc93d96a9c3
parent95a270c87104e1225d4c29a54611f5e4f7a76b56 (diff)
downloadgitlab-ce-fff5ebdcae6794de35f8eaff15217d8643c83686.tar.gz
Removed some useless code, codestyle changes and removed an index
-rw-r--r--app/models/project.rb6
-rw-r--r--app/models/storage/hashed_project.rb4
-rw-r--r--app/views/admin/application_settings/_form.html.haml2
-rw-r--r--db/migrate/20170802013652_add_storage_fields_to_project.rb2
-rw-r--r--db/schema.rb1
-rw-r--r--spec/models/project_spec.rb4
6 files changed, 7 insertions, 12 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index b84d06fef1e..d9e4d4d192e 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -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
diff --git a/app/models/storage/hashed_project.rb b/app/models/storage/hashed_project.rb
index 91f74b084b6..e6d68a177fe 100644
--- a/app/models/storage/hashed_project.rb
+++ b/app/models/storage/hashed_project.rb
@@ -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
diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml
index 124bbebbb78..959af5c0d13 100644
--- a/app/views/admin/application_settings/_form.html.haml
+++ b/app/views/admin/application_settings/_form.html.haml
@@ -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
diff --git a/db/migrate/20170802013652_add_storage_fields_to_project.rb b/db/migrate/20170802013652_add_storage_fields_to_project.rb
index e99ae53ef11..c2381a9d0b2 100644
--- a/db/migrate/20170802013652_add_storage_fields_to_project.rb
+++ b/db/migrate/20170802013652_add_storage_fields_to_project.rb
@@ -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
diff --git a/db/schema.rb b/db/schema.rb
index 4d999ead607..cd488630237 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -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|
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 8ff25a6cf6b..ec620070cdf 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -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