diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-04-13 11:20:07 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-04-19 13:09:51 +0300 |
commit | a28f25b565c58088d80545ebe483f8cd25c22c10 (patch) | |
tree | b2d1c6ff5e0c5bbed3b1f594c07eff1a9ba997c6 /app/models/lfs_object.rb | |
parent | 2c7c8db6a52fb324d72ce14c1c77212826a86b6a (diff) |
Fix direct_upload when records with null file_store are used
Old records have a null value of file_store column.
This causes the problems with current direct_upload implementation,
as this makes it to choose Store::REMOTE instead of Store::LOCAL.
This change moves the store save when change saving the object.
Diffstat (limited to 'app/models/lfs_object.rb')
-rw-r--r-- | app/models/lfs_object.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/app/models/lfs_object.rb b/app/models/lfs_object.rb index b7de46fa202..6b7f280fb70 100644 --- a/app/models/lfs_object.rb +++ b/app/models/lfs_object.rb @@ -11,10 +11,12 @@ class LfsObject < ActiveRecord::Base mount_uploader :file, LfsObjectUploader - before_save :update_file_store + after_save :update_file_store def update_file_store - self.file_store = file.object_store + # The file.object_store is set during `uploader.store!` + # which happens after object is inserted/updated + self.update_column(:file_store, file.object_store) end def project_allowed_access?(project) |