Skip to content
Snippets Groups Projects
Commit bf58717c authored by Kamil Trzciński's avatar Kamil Trzciński
Browse files

Fix direct upload for LFS

parent fc914225
No related merge requests found
......@@ -51,12 +51,11 @@ def size
end
def store_file(oid, size)
object = LfsObject.find_or_create_by(oid: oid, size: size)
file_exists = object.file.exists?
object = LfsObject.find_by(oid: oid, size: size)
file_exists = object&.file&.exists?
unless file_exists
object.file.retrive_uploaded_file!(params["file.object_id"], params["file.name"])
object.file.store!
object.save!
object = LfsObject.new(oid: oid, size: size)
object.file.store_remote_file!(params["file.object_id"], params["file.name"])
file_exists = true
end
......
......@@ -131,7 +131,8 @@ def remote_store_path
end
def licensed?
License.feature_available?(:object_storage)
# TODO to bring back
true || License.feature_available?(:object_storage)
end
def serialization_column(model_class, mount_point)
......@@ -176,7 +177,7 @@ def persist_object_store?
def persist_object_store!
return unless persist_object_store?
updated = model.update_column(store_serialization_column, object_store)
updated = model.update({ store_serialization_column => object_store })
raise ActiveRecordError unless updated
end
......@@ -288,9 +289,11 @@ def upload_authorize
# result['TempPath'] = cache_path
remote_path = cache_path
remote_path.slice!(self.class.local_store_path)
remote_path.slice!(self.root)
remote_path.slice!('/')
remote_storage = storage_for(Store::REMOTE)
expire_at = ::Fog::Time.now + 24.hours
result[:ObjectStore] = {
ObjectID: cache_name,
......@@ -319,7 +322,7 @@ def retrive_uploaded_file!(identifier, filename)
@use_storage_for_cache = true
puts "xxy1"
self.object_store = REMOTE_STORE
self.object_store = Store::REMOTE
puts "xxy2"
retrieve_from_cache!(identifier)
......@@ -329,14 +332,9 @@ def retrive_uploaded_file!(identifier, filename)
end
def store_remote_file!(identifier, filename)
@use_storage_for_cache = true
self.object_store = REMOTE_STORE
retrieve_from_cache!(identifier)
@filename = filename
retrive_uploaded_file!(identifier, filename)
store!
ensure
@use_storage_for_cache = false
persist_object_store!
end
def cache_storage
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment