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]:

View File

@@ -3946,8 +3946,8 @@ class Download_File(Cmdlet):
final_output_dir = resolve_output_dir(config)
except Exception:
import tempfile
final_output_dir = Path(tempfile.gettempdir()) / "Medios-Macina"
final_output_dir = Path(tempfile.gettempdir())
debug(f"Using default directory: {final_output_dir}")
# Ensure directory exists

View File

@@ -30,7 +30,7 @@ class Get_File(sh.Cmdlet):
super().__init__(
name="get-file",
summary="Export file to local path",
usage="@1 | get-file -path C:\\Downloads",
usage="@1 | get-file -path ./output",
arg=[
sh.SharedArgs.QUERY,
sh.SharedArgs.STORE,

View File

@@ -8,6 +8,7 @@ from __future__ import annotations
import hashlib
import sys
import tempfile
import time
from datetime import datetime
import httpx
@@ -948,9 +949,9 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
except Exception:
pass
# Default: User's Videos directory
# Default: system temp directory
if screenshot_dir is None:
screenshot_dir = Path.home() / "Videos"
screenshot_dir = Path(tempfile.gettempdir())
debug(f"[screen_shot] Using default directory: {screenshot_dir}")
ensure_directory(screenshot_dir)

View File

@@ -47,7 +47,7 @@ CMDLET = Cmdlet(
CmdletArg(
"-outdir",
description=
"Output directory for the clip (defaults to source folder for local files; otherwise uses config temp/videos).",
"Output directory for the clip (defaults to source folder for local files; otherwise uses system temp).",
),
CmdletArg(
"-delete",