Skip to content

Commit

Permalink
set filetime for files in ZIP
Browse files Browse the repository at this point in the history
  • Loading branch information
verybadsoldier committed Aug 24, 2018
1 parent f71a0ef commit d230eb3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sacredboard/app/data/pymongo/filesdao.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, generic_dao: GenericDAO):

self._fs = gridfs.GridFS(self.generic_dao._database)

def get(self, file_id: Union[str, bson.ObjectId]):
def get(self, file_id: Union[str, bson.ObjectId]) -> gridfs.GridOut:
"""Return the file identified by a file_id string."""
if isinstance(file_id, str):
file_id = bson.ObjectId(file_id)
Expand Down
6 changes: 4 additions & 2 deletions sacredboard/app/webapi/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import mimetypes
import zipfile

import gridfs

from flask import Blueprint, current_app, render_template, send_file, Response

from sacredboard.app.data import NotFoundError
Expand Down Expand Up @@ -83,8 +85,8 @@ def get_files_zip(run_id: int, filetype: _FileType):
for f in target_files:
# source and artifact files use a different data structure
file_id = f['file_id'] if 'file_id' in f else f[1]
file = dao_files.get(file_id)
data = zipfile.ZipInfo(file.filename)
file: gridfs.GridOut = dao_files.get(file_id)
data = zipfile.ZipInfo(file.filename, date_time=file.upload_date.timetuple())
data.compress_type = zipfile.ZIP_DEFLATED
zf.writestr(data, file.read())
memory_file.seek(0)
Expand Down

0 comments on commit d230eb3

Please sign in to comment.