fix: switch to epoch seconds to allow for win path

pull/5/head
rrr-marble 4 years ago
parent 576b23b2c9
commit a1cd63eca0

@ -187,6 +187,8 @@ async def photo_points():
}
for point in points
]
@app.post(
"/upload_pictures",
responses={
@ -221,7 +223,7 @@ async def upload_pictures(
tasks.add_task(
unpack_pictures_zip,
file=file,
time=datetime.utcnow().replace(microsecond=0).isoformat(),
time=datetime.utcnow().replace(microsecond=0),
)
# feed the pictures to util/import_photos.py
@ -240,8 +242,8 @@ def unpack_pictures_zip(file: UploadFile, time):
import os
from shutil import rmtree
print(f"Accepted {file.filename} at {time} into processing")
processing_path = os.path.join(DATA_LOCATION, "processing" + time)
print(f"Accepted {file.filename} at {time.isoformat()} into processing")
processing_path = os.path.join(DATA_LOCATION, "processing" + str(time.timestamp()))
os.makedirs(processing_path, exist_ok=True)
# using private ._file field is a dirty hack, but
@ -251,11 +253,13 @@ 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} from {time} at {problem_files}")
print(
f"Errors in {file.filename} from {time.isoformat()} at {problem_files}"
)
photo_zip.extractall(path=processing_path)
photo_zip.close()
print(f"Start processing {file.filename} from {time}")
print(f"Start processing {file.filename} from {time.isoformat()}")
iph.check_database(database_path=DB_LOCATION)
for (dir, _, _) in os.walk(processing_path):
@ -268,4 +272,4 @@ def unpack_pictures_zip(file: UploadFile, time):
rmtree(processing_path)
print(f"Succesfully processed {file.filename} from {time}")
print(f"Succesfully processed {file.filename} from {time.isoformat()}")

Loading…
Cancel
Save