Add timestamp to CSV/SQL export filenames
linkvault-links.csv/.sql -> linkvault-links_2026-07-30_1542.csv/.sql, so repeated exports don't just overwrite the same downloaded file. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
10
app/main.py
10
app/main.py
@@ -835,10 +835,13 @@ def export_csv(request: Request, db: Session = Depends(get_db)):
|
|||||||
select(Link).where(Link.user_id == user.id).order_by(Link.created_at)
|
select(Link).where(Link.user_id == user.id).order_by(Link.created_at)
|
||||||
).all()
|
).all()
|
||||||
)
|
)
|
||||||
|
stamp = datetime.now().strftime("%Y-%m-%d_%H%M")
|
||||||
return Response(
|
return Response(
|
||||||
backup.to_csv(links),
|
backup.to_csv(links),
|
||||||
media_type="text/csv; charset=utf-8",
|
media_type="text/csv; charset=utf-8",
|
||||||
headers={"Content-Disposition": "attachment; filename=linkvault-links.csv"},
|
headers={
|
||||||
|
"Content-Disposition": f"attachment; filename=linkvault-links_{stamp}.csv"
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -852,10 +855,13 @@ def export_sql(request: Request, db: Session = Depends(get_db)):
|
|||||||
select(Link).where(Link.user_id == user.id).order_by(Link.created_at)
|
select(Link).where(Link.user_id == user.id).order_by(Link.created_at)
|
||||||
).all()
|
).all()
|
||||||
)
|
)
|
||||||
|
stamp = datetime.now().strftime("%Y-%m-%d_%H%M")
|
||||||
return Response(
|
return Response(
|
||||||
backup.to_sql_dump(links),
|
backup.to_sql_dump(links),
|
||||||
media_type="application/sql; charset=utf-8",
|
media_type="application/sql; charset=utf-8",
|
||||||
headers={"Content-Disposition": "attachment; filename=linkvault-links.sql"},
|
headers={
|
||||||
|
"Content-Disposition": f"attachment; filename=linkvault-links_{stamp}.sql"
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user