ref: use explicit paths instead of chdir

pull/5/head
rrr-marble 4 years ago
parent 822e512a01
commit 250f09153d

@ -225,9 +225,7 @@ def unpack_pictures_zip(file: UploadFile, time):
import os
print(f"Accepted {file.filename} at {time} into processing")
os.chdir(DATA_LOCATION)
os.makedirs("processing", exist_ok=True)
os.chdir("processing")
os.makedirs(os.path.join(DATA_LOCATION, "processing"), exist_ok=True)
# using private ._file field is a dirty hack, but
# SpooledTemporaryFile does not implement seekable
@ -236,7 +234,10 @@ def unpack_pictures_zip(file: UploadFile, time):
with zipfile.ZipFile(file.file._file) as photo_zip:
problem_files = photo_zip.testzip()
if problem_files is not None:
print(f"Errors in {file.filename} accepted at {time}: {problem_files}")
photo_zip.extractall()
print(f"Errors in {file.filename} from {time} at {problem_files}")
photo_zip.extractall(path=os.path.join(DATA_LOCATION, "processing"))
photo_zip.close()
print(f"Succesfully processed {file.filename} accepted at {time}")
print(f"Start processing {file.filename} from {time}")
print(f"Succesfully processed {file.filename} from {time}")

Loading…
Cancel
Save