feat: Introduce initial web frontend and backend services, and generalize directory configuration in docker-compose.
This commit is contained in:
+19
-1
@@ -52,7 +52,7 @@ SUPPORTED_EXTENSIONS = {
|
||||
|
||||
|
||||
def load_vault_config() -> Dict[str, Dict[str, Any]]:
|
||||
"""Read VAULT_N_* env vars and return vault configuration.
|
||||
"""Read VAULT_N_* and DIR_N_* env vars and return vault configuration.
|
||||
|
||||
Scans environment variables ``VAULT_1_NAME``/``VAULT_1_PATH``,
|
||||
``VAULT_2_NAME``/``VAULT_2_PATH``, etc. in sequential order.
|
||||
@@ -67,6 +67,7 @@ def load_vault_config() -> Dict[str, Dict[str, Any]]:
|
||||
- path: filesystem path (required)
|
||||
- attachmentsPath: relative attachments folder (optional)
|
||||
- scanAttachmentsOnStartup: boolean (default True)
|
||||
- type: "VAULT" or "DIR"
|
||||
"""
|
||||
vaults: Dict[str, Dict[str, Any]] = {}
|
||||
n = 1
|
||||
@@ -84,8 +85,25 @@ def load_vault_config() -> Dict[str, Dict[str, Any]]:
|
||||
"path": path,
|
||||
"attachmentsPath": attachments_path,
|
||||
"scanAttachmentsOnStartup": scan_attachments,
|
||||
"type": "VAULT"
|
||||
}
|
||||
n += 1
|
||||
|
||||
n = 1
|
||||
while True:
|
||||
name = os.environ.get(f"DIR_{n}_NAME")
|
||||
path = os.environ.get(f"DIR_{n}_PATH")
|
||||
if not name or not path:
|
||||
break
|
||||
|
||||
vaults[name] = {
|
||||
"path": path,
|
||||
"attachmentsPath": None,
|
||||
"scanAttachmentsOnStartup": False,
|
||||
"type": "DIR"
|
||||
}
|
||||
n += 1
|
||||
|
||||
return vaults
|
||||
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ class VaultInfo(BaseModel):
|
||||
name: str = Field(description="Display name of the vault")
|
||||
file_count: int = Field(description="Number of indexed files")
|
||||
tag_count: int = Field(description="Number of unique tags")
|
||||
type: str = Field(default="VAULT", description="Type of the vault mapping (VAULT or DIR)")
|
||||
|
||||
|
||||
class BrowseItem(BaseModel):
|
||||
@@ -603,10 +604,12 @@ async def api_vaults(current_user=Depends(require_auth)):
|
||||
result = []
|
||||
for name, data in index.items():
|
||||
if "*" in user_vaults or name in user_vaults:
|
||||
v_type = vault_config.get(name, {}).get("type", "VAULT")
|
||||
result.append({
|
||||
"name": name,
|
||||
"file_count": len(data["files"]),
|
||||
"tag_count": len(data["tags"]),
|
||||
"type": v_type,
|
||||
})
|
||||
return result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user