lib/vos/drivers/s3_vfs_storage.rb in vos-0.3.15 vs lib/vos/drivers/s3_vfs_storage.rb in vos-0.4.0

- old
+ new

@@ -21,28 +21,23 @@ def attributes path path = normalize_path(path) return {dir: true, file: false} if path.empty? file = bucket.objects[path] - - attrs = {} - file_exists = file.exists? - attrs[:file] = file_exists - if file_exists + if file.exists? + attrs = {} + attrs[:file] = true attrs[:dir] = false - elsif dir_exists? path - attrs[:dir] = true + attrs[:size] = file.content_length + attrs[:updated_at] = file.last_modified + attrs + # There's no dirs, always returning false + # elsif dir_exists? path + # attrs[:dir] = true else return nil end - - if file_exists - attrs[:size] = file.content_length - attrs[:updated_at] = file.last_modified - end - - attrs end def set_attributes path, attrs raise 'not supported' end @@ -56,24 +51,21 @@ block.call file.read end def write_file original_path, append, &block path = normalize_path original_path - # TODO2 Performance lost, extra call to check file existence - file = bucket.objects[path] - file_exist = file.exists? - raise "can't write, file #{original_path} already exist!" if !append and file_exist + file = bucket.objects[path] if append # there's no support for :append in Fog, so we just mimic it writer = Writer.new - writer.write file.read if file_exist + writer.write file.read if file.exists? block.call writer - file.write writer.data + file.write writer.data, acl: acl else writer = Writer.new block.call writer - file.write writer.data + file.write writer.data, acl: acl end end def delete_file path path = normalize_path path \ No newline at end of file