fix: remove_recent() — nettoie les fichiers récents après suppression
All checks were successful
CI / lint (push) Successful in 13s
CI / security (push) Successful in 8s
CI / test (push) Successful in 15s
CI / build (push) Successful in 2s

This commit is contained in:
Bruno Charest 2026-05-29 21:27:18 -04:00
parent 1243782b6a
commit 279e632b4b
2 changed files with 12 additions and 1 deletions

View File

@ -70,6 +70,14 @@ def get_recent_opened(username: str, vault_filter: Optional[str] = None, limit:
return history[:limit]
def remove_recent(username: str, vault: str, path: str):
"""Remove a file from the recent history (e.g., after deletion)."""
if not username:
return
history = _read_data(_get_history_file(username))
history = [item for item in history if not (item["vault"] == vault and item["path"] == path)]
_write_data(_get_history_file(username), history)
def toggle_bookmark(username: str, vault: str, path: str, title: str = ""):
"""Toggle a file as bookmark for a user. Returns True if bookmarked, False if removed."""
if not username:

View File

@ -49,7 +49,7 @@ from backend.vault_settings import (
get_vault_setting,
update_vault_setting,
)
from backend.history import record_open, get_recent_opened, toggle_bookmark, get_bookmarks, is_bookmarked
from backend.history import record_open, get_recent_opened, remove_recent, toggle_bookmark, get_bookmarks, is_bookmarked
logging.basicConfig(
level=logging.INFO,
@ -1372,6 +1372,9 @@ async def api_file_delete(vault_name: str, path: str = Query(..., description="R
"path": path,
})
# Remove from recent files
remove_recent(current_user["username"], vault_name, path)
# Dispatch webhooks
await dispatch_webhooks("file_deleted", {"vault": vault_name, "path": path})