Added upload and modify dates

This commit is contained in:
2023-01-10 15:23:49 +01:00
parent 906674fcdb
commit c693756a43
2 changed files with 38 additions and 5 deletions

View File

@@ -76,7 +76,23 @@ async def photo_upload(file: UploadFile, album: str, ignore_duplicates: bool = F
)
coords = extract_location(path.join("data", "users", current_user.user, "albums", album, filename))
uploaded = col_photos.insert_one( {"user": current_user.user, "album": album, "hash": file_hash, "filename": filename, "location": [coords["lng"], coords["lat"], coords["alt"]]} )
uploaded = col_photos.insert_one(
{
"user": current_user.user,
"album": album,
"hash": file_hash,
"filename": filename,
"dates": {
"uploaded": datetime.utcnow(),
"modifies": datetime.utcnow()
},
"location": [
coords["lng"],
coords["lat"],
coords["alt"]
]
}
)
if compress is True:
scheduler.add_job(compress_image, trigger="date", run_date=datetime.now()+timedelta(seconds=1), args=[path.join("data", "users", current_user.user, "albums", album, filename)])
@@ -128,7 +144,7 @@ async def photo_move(id: str, album: str, current_user: User = Security(get_curr
else:
filename = image["filename"]
col_photos.find_one_and_update( {"_id": ObjectId(id)}, {"$set": {"album": album, "filename": filename}} )
col_photos.find_one_and_update( {"_id": ObjectId(id)}, {"$set": {"album": album, "filename": filename, "dates.modified": datetime.utcnow()}} )
move(
path.join("data", "users", current_user.user, "albums", image["album"], image["filename"]),