[fix] Corrections ruff CI (UP017/UP041/UP012/I001/F401/FURB162) : backend/services/vaults.py
This commit is contained in:
@@ -7,6 +7,7 @@ Single source of truth consumed by both the REST routes (``/api/vaults``,
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from datetime import UTC
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
@@ -49,7 +50,7 @@ def get_vault_root(vault_name: str) -> Path:
|
|||||||
|
|
||||||
def browse_directory(vault_name: str, path: str = "") -> dict[str, Any]:
|
def browse_directory(vault_name: str, path: str = "") -> dict[str, Any]:
|
||||||
"""Return the direct children of a vault directory (directories first)."""
|
"""Return the direct children of a vault directory (directories first)."""
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime
|
||||||
|
|
||||||
from backend.indexer import SUPPORTED_EXTENSIONS
|
from backend.indexer import SUPPORTED_EXTENSIONS
|
||||||
from backend.vault_settings import get_vault_setting
|
from backend.vault_settings import get_vault_setting
|
||||||
@@ -98,7 +99,7 @@ def browse_directory(vault_name: str, path: str = "") -> dict[str, Any]:
|
|||||||
"type": "file",
|
"type": "file",
|
||||||
"size": stat.st_size,
|
"size": stat.st_size,
|
||||||
"modified": stat.st_mtime,
|
"modified": stat.st_mtime,
|
||||||
"modified_iso": datetime.fromtimestamp(stat.st_mtime, tz=timezone.utc).isoformat(),
|
"modified_iso": datetime.fromtimestamp(stat.st_mtime, tz=UTC).isoformat(),
|
||||||
"extension": entry.suffix.lower(),
|
"extension": entry.suffix.lower(),
|
||||||
})
|
})
|
||||||
except PermissionError:
|
except PermissionError:
|
||||||
@@ -156,7 +157,7 @@ def list_all_files(
|
|||||||
ServiceError: ``not_found`` (404) if the directory does not exist,
|
ServiceError: ``not_found`` (404) if the directory does not exist,
|
||||||
``permission_denied`` (403) if it cannot be read.
|
``permission_denied`` (403) if it cannot be read.
|
||||||
"""
|
"""
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime
|
||||||
|
|
||||||
from backend.indexer import IGNORED_DIRS
|
from backend.indexer import IGNORED_DIRS
|
||||||
|
|
||||||
@@ -215,7 +216,7 @@ def list_all_files(
|
|||||||
"vault": vault_name,
|
"vault": vault_name,
|
||||||
"size": stat.st_size,
|
"size": stat.st_size,
|
||||||
"modified": stat.st_mtime,
|
"modified": stat.st_mtime,
|
||||||
"modified_iso": datetime.fromtimestamp(stat.st_mtime, tz=timezone.utc).isoformat(),
|
"modified_iso": datetime.fromtimestamp(stat.st_mtime, tz=UTC).isoformat(),
|
||||||
"extension": ext.lstrip(".") if ext else "",
|
"extension": ext.lstrip(".") if ext else "",
|
||||||
"tags": _indexed_tags(vault_name, rel_path),
|
"tags": _indexed_tags(vault_name, rel_path),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user