diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2016-08-10 17:49:23 +0300 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2016-08-10 17:49:23 +0300 |
commit | f817eecb22517ece0344977d00ecc7ddfff30594 (patch) | |
tree | 49a1b08e188fc7919811625be9e26ebb3dd11006 /app | |
parent | 0012de8c8a6642db40c13273f32c396afaa629eb (diff) |
Use && and || instead of if
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/lfs_storage_controller.rb | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/app/controllers/projects/lfs_storage_controller.rb b/app/controllers/projects/lfs_storage_controller.rb index 6bde0a527ff..a80fa525631 100644 --- a/app/controllers/projects/lfs_storage_controller.rb +++ b/app/controllers/projects/lfs_storage_controller.rb @@ -68,22 +68,13 @@ class Projects::LfsStorageController < Projects::GitHttpClientController end def store_file(oid, size, tmp_file) + # Define tmp_file_path early because we use it in "ensure" tmp_file_path = File.join("#{Gitlab.config.lfs.storage_path}/tmp/upload", tmp_file) object = LfsObject.find_or_create_by(oid: oid, size: size) - if object.file.exists? - success = true - else - success = move_tmp_file_to_storage(object, tmp_file_path) - end - - if success - success = link_to_project(object) - end - - success + file_exists = object.file.exists? || move_tmp_file_to_storage(object, tmp_file_path) + file_exists && link_to_project(object) ensure - # Ensure that the tmp file is removed FileUtils.rm_f(tmp_file_path) end |