fix: remove_recent() — nettoie les fichiers récents après suppression
This commit is contained in:
@@ -70,6 +70,14 @@ def get_recent_opened(username: str, vault_filter: Optional[str] = None, limit:
|
|||||||
|
|
||||||
return history[: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 = ""):
|
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."""
|
"""Toggle a file as bookmark for a user. Returns True if bookmarked, False if removed."""
|
||||||
if not username:
|
if not username:
|
||||||
|
|||||||
+4
-1
@@ -49,7 +49,7 @@ from backend.vault_settings import (
|
|||||||
get_vault_setting,
|
get_vault_setting,
|
||||||
update_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(
|
logging.basicConfig(
|
||||||
level=logging.INFO,
|
level=logging.INFO,
|
||||||
@@ -1372,6 +1372,9 @@ async def api_file_delete(vault_name: str, path: str = Query(..., description="R
|
|||||||
"path": path,
|
"path": path,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# Remove from recent files
|
||||||
|
remove_recent(current_user["username"], vault_name, path)
|
||||||
|
|
||||||
# Dispatch webhooks
|
# Dispatch webhooks
|
||||||
await dispatch_webhooks("file_deleted", {"vault": vault_name, "path": path})
|
await dispatch_webhooks("file_deleted", {"vault": vault_name, "path": path})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user