refactor: remove hidden files indexing configuration and convert to UI-only display preference, eliminating includeHidden and hiddenWhitelist from vault config and indexing logic while adding hideHiddenFiles client-side filtering
This commit is contained in:
+13
-31
@@ -1414,32 +1414,28 @@ async def api_attachment_stats(vault: Optional[str] = Query(None, description="V
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Vault Settings API — Hidden files configuration
|
||||
# Vault Settings API — Display preferences
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@app.get("/api/vaults/{vault_name}/settings")
|
||||
async def api_get_vault_settings(vault_name: str, current_user=Depends(require_auth)):
|
||||
"""Get settings for a specific vault including hidden files configuration.
|
||||
"""Get UI display settings for a specific vault.
|
||||
|
||||
Args:
|
||||
vault_name: Name of the vault.
|
||||
|
||||
Returns:
|
||||
Dict with vault settings including includeHidden and hiddenWhitelist.
|
||||
Dict with vault settings including hideHiddenFiles.
|
||||
"""
|
||||
if vault_name not in index:
|
||||
raise HTTPException(status_code=404, detail=f"Vault '{vault_name}' not found")
|
||||
|
||||
# Get current vault config from environment
|
||||
vault_cfg = vault_config.get(vault_name, {})
|
||||
|
||||
# Get persisted settings
|
||||
persisted = get_vault_setting(vault_name) or {}
|
||||
|
||||
# Merge with defaults
|
||||
# Default settings
|
||||
settings = {
|
||||
"includeHidden": vault_cfg.get("includeHidden", False),
|
||||
"hiddenWhitelist": vault_cfg.get("hiddenWhitelist", []),
|
||||
"hideHiddenFiles": False,
|
||||
}
|
||||
settings.update(persisted)
|
||||
|
||||
@@ -1448,11 +1444,11 @@ async def api_get_vault_settings(vault_name: str, current_user=Depends(require_a
|
||||
|
||||
@app.post("/api/vaults/{vault_name}/settings")
|
||||
async def api_update_vault_settings(vault_name: str, body: dict = Body(...), current_user=Depends(require_admin)):
|
||||
"""Update settings for a specific vault.
|
||||
"""Update UI display settings for a specific vault.
|
||||
|
||||
Args:
|
||||
vault_name: Name of the vault.
|
||||
body: Dict with settings to update (includeHidden, hiddenWhitelist).
|
||||
body: Dict with settings to update (hideHiddenFiles).
|
||||
|
||||
Returns:
|
||||
Updated settings dict.
|
||||
@@ -1463,18 +1459,10 @@ async def api_update_vault_settings(vault_name: str, body: dict = Body(...), cur
|
||||
# Validate settings
|
||||
settings_to_update = {}
|
||||
|
||||
if "includeHidden" in body:
|
||||
if not isinstance(body["includeHidden"], bool):
|
||||
raise HTTPException(status_code=400, detail="includeHidden must be a boolean")
|
||||
settings_to_update["includeHidden"] = body["includeHidden"]
|
||||
|
||||
if "hiddenWhitelist" in body:
|
||||
if not isinstance(body["hiddenWhitelist"], list):
|
||||
raise HTTPException(status_code=400, detail="hiddenWhitelist must be a list")
|
||||
# Validate each item is a string
|
||||
if not all(isinstance(item, str) for item in body["hiddenWhitelist"]):
|
||||
raise HTTPException(status_code=400, detail="All hiddenWhitelist items must be strings")
|
||||
settings_to_update["hiddenWhitelist"] = body["hiddenWhitelist"]
|
||||
if "hideHiddenFiles" in body:
|
||||
if not isinstance(body["hideHiddenFiles"], bool):
|
||||
raise HTTPException(status_code=400, detail="hideHiddenFiles must be a boolean")
|
||||
settings_to_update["hideHiddenFiles"] = body["hideHiddenFiles"]
|
||||
|
||||
# Update persisted settings
|
||||
try:
|
||||
@@ -1492,10 +1480,6 @@ async def api_update_vault_settings(vault_name: str, body: dict = Body(...), cur
|
||||
detail=f"Failed to save settings: {str(e)}"
|
||||
)
|
||||
|
||||
# Update in-memory vault config
|
||||
if vault_name in vault_config:
|
||||
vault_config[vault_name].update(settings_to_update)
|
||||
|
||||
logger.info(f"Updated settings for vault '{vault_name}': {settings_to_update}")
|
||||
|
||||
return updated
|
||||
@@ -1503,7 +1487,7 @@ async def api_update_vault_settings(vault_name: str, body: dict = Body(...), cur
|
||||
|
||||
@app.get("/api/vaults/settings/all")
|
||||
async def api_get_all_vault_settings(current_user=Depends(require_auth)):
|
||||
"""Get settings for all vaults.
|
||||
"""Get UI display settings for all vaults.
|
||||
|
||||
Returns:
|
||||
Dict mapping vault names to their settings.
|
||||
@@ -1511,12 +1495,10 @@ async def api_get_all_vault_settings(current_user=Depends(require_auth)):
|
||||
all_settings = {}
|
||||
|
||||
for vault_name in index.keys():
|
||||
vault_cfg = vault_config.get(vault_name, {})
|
||||
persisted = get_vault_setting(vault_name) or {}
|
||||
|
||||
settings = {
|
||||
"includeHidden": vault_cfg.get("includeHidden", False),
|
||||
"hiddenWhitelist": vault_cfg.get("hiddenWhitelist", []),
|
||||
"hideHiddenFiles": False,
|
||||
}
|
||||
settings.update(persisted)
|
||||
all_settings[vault_name] = settings
|
||||
|
||||
Reference in New Issue
Block a user