Skip to content

Commit

Permalink
Add requsted changes
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfarkas committed Mar 8, 2018
1 parent ddc0232 commit 08d5016
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
5 changes: 3 additions & 2 deletions api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
'db_server_selection_timeout': '3000',
'data_path': os.path.join(os.path.dirname(__file__), '../persistent/data'),
'elasticsearch_host': 'localhost:9200',
'fs_url': 'osfs://' + os.path.join(os.path.dirname(__file__), '../persistent/data')
'fs_url': 'osfs://' + os.path.join(os.path.dirname(__file__), '../persistent/data'),
'support_legacy_fs': True
},
}

Expand Down Expand Up @@ -329,4 +330,4 @@ def get_auth(auth_type):
# Storage configuration
fs = open_fs(__config['persistent']['fs_url'])
legacy_fs = open_fs('osfs://' + __config['persistent']['data_path'])
support_legacy_fs = True
support_legacy_fs = __config['persistent']['support_legacy_fs']
5 changes: 4 additions & 1 deletion api/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ def _FieldStorage__write(self, line):
self._FieldStorage__file = None

self.file.write(line)
if hasattr(self, 'hasher'):

# NOTE: In case of metadata, we don't have a file name and we also don't have a hasher,
# so skipping the hasher.update
if self.filename:
self.hasher.update(line)

return SingleFileFieldStorage
Expand Down
20 changes: 10 additions & 10 deletions api/handlers/listhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,17 +363,17 @@ def build_zip_info(file_path, file_system):
"""
with file_system.open(file_path, 'rb') as f:
with zipfile.ZipFile(f) as zf:
info = {}
info['comment'] = zf.comment
info['members'] = []
info = {
'comment': zf.comment,
'members': []
}
for zi in zf.infolist():
m = {}
m['path'] = zi.filename
m['size'] = zi.file_size
m['timestamp'] = datetime.datetime(*zi.date_time)
m['comment'] = zi.comment

info['members'].append(m)
info['members'].append({
'path': zi.filename,
'size': zi.file_size,
'timestamp': datetime.datetime(*zi.date_time),
'comment': zi.comment
})

return info

Expand Down
9 changes: 3 additions & 6 deletions api/placer.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ def save_file(self, field=None, file_attrs=None):
if field is not None and self.file_processor is not None:
self.file_processor.store_temp_file(field.path, util.path_from_uuid(field.uuid))

# if field is not None:
# files.move_form_file_field_into_storage(field)

# Update the DB
if file_attrs is not None:
container_before, self.container = hierarchy.upsert_fileinfo(self.container_type, self.id_, file_attrs)
Expand Down Expand Up @@ -507,13 +504,13 @@ def finalize(self):
# Write all files to zip
complete = 0
for path in paths:
p = fs.path.join(self.folder, path)
full_path = fs.path.join(self.folder, path)

# Set the file's mtime & atime.
self.file_processor.persistent_fs.settimes(p, self.ziptime, self.ziptime)
self.file_processor.persistent_fs.settimes(full_path, self.ziptime, self.ziptime)

# Place file into the zip folder we created before
with self.file_processor.persistent_fs.open(p, 'rb') as f:
with self.file_processor.persistent_fs.open(full_path, 'rb') as f:
self.zip_.writestr(fs.path.join(self.dir_, path), f.read())

# Report progress
Expand Down

0 comments on commit 08d5016

Please sign in to comment.