This commit is contained in:
2026-01-11 10:59:50 -08:00
parent 5f8f49c530
commit 234f7aca5c
9 changed files with 112 additions and 53 deletions

View File

@@ -65,7 +65,7 @@ class CmdletArg:
Example:
# For STORAGE arg with a handler
storage_path = SharedArgs.STORAGE.resolve('local') # Returns Path.home() / "Videos"
storage_path = SharedArgs.STORAGE.resolve('local') # Returns Path(tempfile.gettempdir())
"""
if self.handler is not None and callable(self.handler):
return self.handler(value)
@@ -354,47 +354,29 @@ class SharedArgs:
) -> Path:
"""Resolve a storage location name to a filesystem Path.
Maps storage identifiers (hydrus, local, ftp) to their actual
filesystem paths. This is the single source of truth for storage location resolution.
Note: 0x0.st is now accessed via file providers (-provider 0x0), not storage.
Maps storage identifiers to their actual filesystem paths.
This project has been refactored to use system temporary directories
for all staging/downloads by default.
Args:
storage_value: One of 'hydrus', 'local', 'ftp', or None
default: Path to return if storage_value is None (defaults to Videos)
storage_value: One of 'hydrus', 'local', 'ftp', or None (currently unified to temp)
default: Path to return if storage_value is None (defaults to temp directory)
Returns:
Resolved Path object for the storage location
Raises:
ValueError: If storage_value is not a recognized storage type
Resolved Path object for the storage location (typically system temp)
Example:
# In a cmdlet:
storage_path = SharedArgs.resolve_storage(parsed.storage)
# With defaults:
path = SharedArgs.resolve_storage(None) # Returns home/Videos
path = SharedArgs.resolve_storage('local') # Returns home/Videos
path = SharedArgs.resolve_storage('hydrus') # Returns home/.hydrus/client_files
storage_path = SharedArgs.resolve_storage(parsed.get('storage'))
# Returns Path(tempfile.gettempdir())
"""
storage_map = {
"local": Path.home() / "Videos",
"hydrus": Path.home() / ".hydrus" / "client_files",
"ftp": Path.home() / "FTP",
"matrix": Path.home() / "Matrix", # Placeholder, not used for upload path
}
# We no longer maintain a hardcoded map for 'hydrus' (~/.hydrus) or 'local' (~/Videos).
# Everything defaults to the system temp directory unless a specific default is provided.
# This ensures environment independence.
if default is not None:
return default
if storage_value is None:
return default or (Path.home() / "Videos")
storage_lower = storage_value.lower()
if storage_lower not in storage_map:
raise ValueError(
f"Unknown storage location '{storage_value}'. "
f"Must be one of: {', '.join(storage_map.keys())}"
)
return storage_map[storage_lower]
return Path(tempfile.gettempdir())
@classmethod
def get(cls, name: str) -> Optional[CmdletArg]: