This commit is contained in:
2026-01-09 01:22:06 -08:00
parent 89ac3bb7e8
commit 1deddfda5c
10 changed files with 1004 additions and 179 deletions

View File

@@ -321,12 +321,10 @@ class Add_File(Cmdlet):
is_storage_backend_location = False
if location:
try:
# Use a config-only check to avoid instantiating backends (which may perform network checks).
from Store.registry import list_configured_backend_names
is_storage_backend_location = location in (
list_configured_backend_names(config) or []
)
# Check against the cached startup list of available backends
from cmdlet._shared import SharedArgs
available_backends = SharedArgs.get_store_choices(config)
is_storage_backend_location = location in available_backends
except Exception:
is_storage_backend_location = False
@@ -546,7 +544,10 @@ class Add_File(Cmdlet):
# Update pipe_obj with resolved path
pipe_obj.path = str(media_path)
if not self._validate_source(media_path):
# When using -path (filesystem export), allow all file types.
# When using -store (backend), restrict to SUPPORTED_MEDIA_EXTENSIONS.
allow_all_files = not (location and is_storage_backend_location)
if not self._validate_source(media_path, allow_all_extensions=allow_all_files):
failures += 1
continue
@@ -1193,8 +1194,15 @@ class Add_File(Cmdlet):
return files_info
@staticmethod
def _validate_source(media_path: Optional[Path]) -> bool:
"""Validate that the source file exists and is supported."""
@staticmethod
def _validate_source(media_path: Optional[Path], allow_all_extensions: bool = False) -> bool:
"""Validate that the source file exists and is supported.
Args:
media_path: Path to the file to validate
allow_all_extensions: If True, skip file type filtering (used for -path exports).
If False, only allow SUPPORTED_MEDIA_EXTENSIONS (used for -store).
"""
if media_path is None:
return False
@@ -1214,11 +1222,12 @@ class Add_File(Cmdlet):
log(f"File not found: {media_path}")
return False
# Validate file type
file_extension = media_path.suffix.lower()
if file_extension not in SUPPORTED_MEDIA_EXTENSIONS:
log(f"❌ Unsupported file type: {file_extension}", file=sys.stderr)
return False
# Validate file type: only when adding to -store backend, not for -path exports
if not allow_all_extensions:
file_extension = media_path.suffix.lower()
if file_extension not in SUPPORTED_MEDIA_EXTENSIONS:
log(f"❌ Unsupported file type: {file_extension}", file=sys.stderr)
return False
return True