From 263717d70c526fb3272f802120669a4cb85c5bf5 Mon Sep 17 00:00:00 2001
From: Kamil Trzcinski <ayufan@ayufan.eu>
Date: Tue, 19 Sep 2017 16:34:10 +0200
Subject: [PATCH] Do not perform hard check (presence of file on storage)

Instead perform soft check (the column set to indicate that file does exist)
---
 app/controllers/projects/uploads_controller.rb      | 2 +-
 app/uploaders/avatar_uploader.rb                    | 2 +-
 app/uploaders/gitlab_uploader.rb                    | 2 +-
 changelogs/unreleased/do-not-perform-disk-check.yml | 5 +++++
 4 files changed, 8 insertions(+), 3 deletions(-)
 create mode 100644 changelogs/unreleased/do-not-perform-disk-check.yml

diff --git a/app/controllers/projects/uploads_controller.rb b/app/controllers/projects/uploads_controller.rb
index 6966a7c5fee..4d2fb17a19b 100644
--- a/app/controllers/projects/uploads_controller.rb
+++ b/app/controllers/projects/uploads_controller.rb
@@ -28,7 +28,7 @@ class Projects::UploadsController < Projects::ApplicationController
   end
 
   def image_or_video?
-    uploader && uploader.file.exists? && uploader.image_or_video?
+    uploader && uploader.exists? && uploader.image_or_video?
   end
 
   def uploader_class
diff --git a/app/uploaders/avatar_uploader.rb b/app/uploaders/avatar_uploader.rb
index 66d3bcb998a..cbb79376d5f 100644
--- a/app/uploaders/avatar_uploader.rb
+++ b/app/uploaders/avatar_uploader.rb
@@ -9,7 +9,7 @@ class AvatarUploader < GitlabUploader
   end
 
   def exists?
-    model.avatar.file && model.avatar.file.exists?
+    model.avatar.file && model.avatar.file.present?
   end
 
   # We set move_to_store and move_to_cache to 'false' to prevent stealing
diff --git a/app/uploaders/gitlab_uploader.rb b/app/uploaders/gitlab_uploader.rb
index 05a2091633a..7f72b3ce471 100644
--- a/app/uploaders/gitlab_uploader.rb
+++ b/app/uploaders/gitlab_uploader.rb
@@ -51,7 +51,7 @@ class GitlabUploader < CarrierWave::Uploader::Base
   end
 
   def exists?
-    file.try(:exists?)
+    file.present?
   end
 
   # Override this if you don't want to save files by default to the Rails.root directory
diff --git a/changelogs/unreleased/do-not-perform-disk-check.yml b/changelogs/unreleased/do-not-perform-disk-check.yml
new file mode 100644
index 00000000000..cc139ee2c9e
--- /dev/null
+++ b/changelogs/unreleased/do-not-perform-disk-check.yml
@@ -0,0 +1,5 @@
+---
+title: File uploaders do not perform hard check, only soft check
+merge_request:
+author:
+type: fixed
-- 
2.30.9