7z seq compression working
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
@echo off
|
@echo off
|
||||||
setlocal EnableExtensions
|
setlocal EnableExtensions EnableDelayedExpansion
|
||||||
|
|
||||||
set "REN_DIR=%~dp0"
|
set "REN_DIR=%~dp0"
|
||||||
for %%I in ("%REN_DIR%..") do set "PROJ_ROOT=%%~fI"
|
for %%I in ("%REN_DIR%..") do set "PROJ_ROOT=%%~fI"
|
||||||
@@ -31,12 +31,12 @@ if not defined PY_SCRIPT (
|
|||||||
pushd "%PROJ_ROOT%" >nul 2>&1
|
pushd "%PROJ_ROOT%" >nul 2>&1
|
||||||
|
|
||||||
python "%PY_SCRIPT%" --mode expand --verbose %*
|
python "%PY_SCRIPT%" --mode expand --verbose %*
|
||||||
set "ERR=%ERRORLEVEL%"
|
set "ERR=!ERRORLEVEL!"
|
||||||
|
|
||||||
if not "%ERR%"=="0" (
|
if not "!ERR!"=="0" (
|
||||||
echo Failed to expand render sequence archives (exit code %ERR%).
|
echo Failed to expand render sequence archives (exit code !ERR!).
|
||||||
)
|
)
|
||||||
|
|
||||||
popd >nul 2>&1
|
popd >nul 2>&1
|
||||||
exit /b %ERR%
|
exit /b !ERR!
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
@echo off
|
@echo off
|
||||||
setlocal EnableExtensions
|
setlocal EnableExtensions EnableDelayedExpansion
|
||||||
|
|
||||||
set "REN_DIR=%~dp0"
|
set "REN_DIR=%~dp0"
|
||||||
for %%I in ("%REN_DIR%..") do set "PROJ_ROOT=%%~fI"
|
for %%I in ("%REN_DIR%..") do set "PROJ_ROOT=%%~fI"
|
||||||
@@ -31,12 +31,12 @@ if not defined PY_SCRIPT (
|
|||||||
pushd "%PROJ_ROOT%" >nul 2>&1
|
pushd "%PROJ_ROOT%" >nul 2>&1
|
||||||
|
|
||||||
python "%PY_SCRIPT%" --verbose %*
|
python "%PY_SCRIPT%" --verbose %*
|
||||||
set "ERR=%ERRORLEVEL%"
|
set "ERR=!ERRORLEVEL!"
|
||||||
|
|
||||||
if not "%ERR%"=="0" (
|
if not "!ERR!"=="0" (
|
||||||
echo Failed to update render sequence archives (exit code %ERR%).
|
echo Failed to update render sequence archives (exit code !ERR!).
|
||||||
)
|
)
|
||||||
|
|
||||||
popd >nul 2>&1
|
popd >nul 2>&1
|
||||||
exit /b %ERR%
|
exit /b !ERR!
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
new script named UpgradeToGitProj. this is to be ran in a project structure that was pre-git.
|
|
||||||
|
|
||||||
1. appends gitignore and gitattributes, initializes git, and installs git lfs
|
|
||||||
- If already initialized, will this just error but continue?
|
|
||||||
2. Manages Renders folder:
|
|
||||||
a. creates folder, adding NewDaily and UpdateSeq scripts
|
|
||||||
b. scans the structure within blends\animations and creates a folder for each submodule, e.g. Horizontal, Shorts, Vertical, etc. If there are no submodules, it just grabs the daily_* folders.
|
|
||||||
c. For each daily_* folder, it copies the contents of each daily_*\seq\ folder into the Renders\submodule\ folder. If it's taking daily_* folders from the root, it just copies the contents of the daily_*\seq\ folder into the Renders\ folder.
|
|
||||||
230
zip_sequences.py
230
zip_sequences.py
@@ -33,7 +33,6 @@ SEQUENCE_EXTENSIONS = {
|
|||||||
".exr",
|
".exr",
|
||||||
}
|
}
|
||||||
STATE_SUFFIX = ".meta.json"
|
STATE_SUFFIX = ".meta.json"
|
||||||
CONFIG_PATH = Path(__file__).resolve().with_name("config.json")
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
"zipper": "7z",
|
"zipper": "7z",
|
||||||
"compression": 9,
|
"compression": 9,
|
||||||
@@ -42,24 +41,34 @@ DEFAULT_CONFIG = {
|
|||||||
|
|
||||||
|
|
||||||
def load_config() -> dict:
|
def load_config() -> dict:
|
||||||
try:
|
# First try to load from project's .config folder (current working directory)
|
||||||
text = CONFIG_PATH.read_text(encoding="utf-8")
|
# Then fall back to ProjectStructure repo config (next to zip_sequences.py)
|
||||||
except FileNotFoundError:
|
cwd = Path.cwd()
|
||||||
return DEFAULT_CONFIG.copy()
|
project_config = cwd / ".config" / "config.json"
|
||||||
except OSError:
|
repo_config = Path(__file__).resolve().with_name("config.json")
|
||||||
return DEFAULT_CONFIG.copy()
|
|
||||||
|
|
||||||
try:
|
config_paths = [
|
||||||
data = json.loads(text)
|
("project", project_config),
|
||||||
except json.JSONDecodeError:
|
("repo", repo_config),
|
||||||
return DEFAULT_CONFIG.copy()
|
]
|
||||||
|
|
||||||
if not isinstance(data, dict):
|
for source, config_path in config_paths:
|
||||||
return DEFAULT_CONFIG.copy()
|
try:
|
||||||
|
if config_path.exists():
|
||||||
|
text = config_path.read_text(encoding="utf-8")
|
||||||
|
try:
|
||||||
|
data = json.loads(text)
|
||||||
|
if isinstance(data, dict):
|
||||||
|
merged = DEFAULT_CONFIG.copy()
|
||||||
|
merged.update(data)
|
||||||
|
return merged
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
continue
|
||||||
|
except OSError:
|
||||||
|
continue
|
||||||
|
|
||||||
merged = DEFAULT_CONFIG.copy()
|
# If no config found, return defaults
|
||||||
merged.update(data)
|
return DEFAULT_CONFIG.copy()
|
||||||
return merged
|
|
||||||
|
|
||||||
|
|
||||||
CONFIG = load_config()
|
CONFIG = load_config()
|
||||||
@@ -69,6 +78,7 @@ if isinstance(zipper_val, bool):
|
|||||||
ZIPPER_TYPE = "7z" if zipper_val else "zip"
|
ZIPPER_TYPE = "7z" if zipper_val else "zip"
|
||||||
else:
|
else:
|
||||||
ZIPPER_TYPE = str(zipper_val).lower()
|
ZIPPER_TYPE = str(zipper_val).lower()
|
||||||
|
|
||||||
COMPRESSION_LEVEL = CONFIG.get("compression", 9)
|
COMPRESSION_LEVEL = CONFIG.get("compression", 9)
|
||||||
if isinstance(COMPRESSION_LEVEL, str):
|
if isinstance(COMPRESSION_LEVEL, str):
|
||||||
try:
|
try:
|
||||||
@@ -82,8 +92,6 @@ COMPRESSION_LEVEL = max(0, min(9, COMPRESSION_LEVEL))
|
|||||||
SEVEN_Z_EXE: str | None = None
|
SEVEN_Z_EXE: str | None = None
|
||||||
if ZIPPER_TYPE == "7z":
|
if ZIPPER_TYPE == "7z":
|
||||||
SEVEN_Z_EXE = shutil.which("7z") or shutil.which("7za")
|
SEVEN_Z_EXE = shutil.which("7z") or shutil.which("7za")
|
||||||
if SEVEN_Z_EXE is None:
|
|
||||||
print("[zip] Warning: 7z compression requested but no 7z executable was found in PATH.", file=sys.stderr)
|
|
||||||
|
|
||||||
|
|
||||||
def parse_args() -> argparse.Namespace:
|
def parse_args() -> argparse.Namespace:
|
||||||
@@ -179,7 +187,8 @@ def state_changed(seq_state: dict, stored_state: dict | None) -> bool:
|
|||||||
|
|
||||||
def archive_path_for(seq_dir: Path) -> Path:
|
def archive_path_for(seq_dir: Path) -> Path:
|
||||||
rel = seq_dir.relative_to(RENDER_ROOT)
|
rel = seq_dir.relative_to(RENDER_ROOT)
|
||||||
return (ARCHIVE_ROOT / rel).with_suffix(".zip")
|
suffix = ".7z" if ZIPPER_TYPE == "7z" else ".zip"
|
||||||
|
return (ARCHIVE_ROOT / rel).with_suffix(suffix)
|
||||||
|
|
||||||
|
|
||||||
def sequence_dir_for(zip_path: Path) -> Path:
|
def sequence_dir_for(zip_path: Path) -> Path:
|
||||||
@@ -194,15 +203,21 @@ def state_path_for(zip_path: Path) -> Path:
|
|||||||
def zip_sequence(seq_dir: Path, zip_path: Path) -> None:
|
def zip_sequence(seq_dir: Path, zip_path: Path) -> None:
|
||||||
if ZIPPER_TYPE == "7z":
|
if ZIPPER_TYPE == "7z":
|
||||||
if SEVEN_Z_EXE is None:
|
if SEVEN_Z_EXE is None:
|
||||||
raise RuntimeError("7z compression requested but 7z executable not found in PATH")
|
raise RuntimeError(
|
||||||
|
"7z compression requested but 7z executable not found in PATH. "
|
||||||
|
"Please install 7z (e.g., via Chocolatey: choco install 7zip) "
|
||||||
|
"or set zipper to 'zip' in config.json"
|
||||||
|
)
|
||||||
zip_path.parent.mkdir(parents=True, exist_ok=True)
|
zip_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
# Remove existing zip file if it exists to avoid corruption issues
|
|
||||||
if zip_path.exists():
|
# If creating a .7z file, remove any existing .zip file for the same sequence
|
||||||
try:
|
if zip_path.suffix == ".7z":
|
||||||
zip_path.unlink()
|
old_zip_path = zip_path.with_suffix(".zip")
|
||||||
except OSError:
|
if old_zip_path.exists():
|
||||||
# If deletion fails, try to overwrite with -aoa flag
|
old_zip_path.unlink(missing_ok=True)
|
||||||
pass
|
old_state_path = state_path_for(old_zip_path)
|
||||||
|
if old_state_path.exists():
|
||||||
|
old_state_path.unlink(missing_ok=True)
|
||||||
|
|
||||||
# Build list of files to archive with relative paths
|
# Build list of files to archive with relative paths
|
||||||
file_list = []
|
file_list = []
|
||||||
@@ -213,9 +228,14 @@ def zip_sequence(seq_dir: Path, zip_path: Path) -> None:
|
|||||||
if not file_list:
|
if not file_list:
|
||||||
raise RuntimeError(f"No files found to archive in {seq_dir}")
|
raise RuntimeError(f"No files found to archive in {seq_dir}")
|
||||||
|
|
||||||
# Use a temporary list file to avoid Windows command line length limits
|
# Create zip in temporary location first to avoid issues with corrupted existing files
|
||||||
|
temp_zip = None
|
||||||
list_file_path = None
|
list_file_path = None
|
||||||
try:
|
try:
|
||||||
|
# Create temporary archive file path (but don't create the file - let 7z create it)
|
||||||
|
temp_zip_path = tempfile.mktemp(suffix=".7z", dir=zip_path.parent)
|
||||||
|
temp_zip = Path(temp_zip_path)
|
||||||
|
|
||||||
# Create list file with absolute path
|
# Create list file with absolute path
|
||||||
fd, temp_path = tempfile.mkstemp(suffix=".lst", text=True)
|
fd, temp_path = tempfile.mkstemp(suffix=".lst", text=True)
|
||||||
list_file_path = Path(temp_path)
|
list_file_path = Path(temp_path)
|
||||||
@@ -227,18 +247,18 @@ def zip_sequence(seq_dir: Path, zip_path: Path) -> None:
|
|||||||
# File is closed here by context manager, small delay to ensure OS releases handle
|
# File is closed here by context manager, small delay to ensure OS releases handle
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
# Use absolute path for list file in 7z command
|
# Use absolute paths for both list file and temp zip
|
||||||
list_file_abs = list_file_path.resolve()
|
list_file_abs = list_file_path.resolve()
|
||||||
# Use -aoa to overwrite all files, -bb0 to suppress progress output
|
temp_zip_abs = temp_zip.resolve()
|
||||||
|
# Create archive in temp location first (7z will create it fresh)
|
||||||
cmd = [
|
cmd = [
|
||||||
SEVEN_Z_EXE,
|
SEVEN_Z_EXE,
|
||||||
"a",
|
"a",
|
||||||
"-y",
|
"-y",
|
||||||
"-aoa", # Overwrite all existing files
|
|
||||||
"-bb0", # Suppress progress output
|
"-bb0", # Suppress progress output
|
||||||
f"-mx={COMPRESSION_LEVEL}",
|
f"-mx={COMPRESSION_LEVEL}",
|
||||||
"-tzip",
|
"-t7z", # Use 7z format, not zip
|
||||||
str(zip_path),
|
str(temp_zip_abs),
|
||||||
f"@{list_file_abs}",
|
f"@{list_file_abs}",
|
||||||
]
|
]
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
@@ -254,7 +274,19 @@ def zip_sequence(seq_dir: Path, zip_path: Path) -> None:
|
|||||||
if result.stdout:
|
if result.stdout:
|
||||||
error_msg += f"\nstdout: {result.stdout.strip()}"
|
error_msg += f"\nstdout: {result.stdout.strip()}"
|
||||||
raise RuntimeError(f"7z compression failed: {error_msg}")
|
raise RuntimeError(f"7z compression failed: {error_msg}")
|
||||||
|
|
||||||
|
# Move temp zip to final location, replacing any existing file
|
||||||
|
if zip_path.exists():
|
||||||
|
zip_path.unlink()
|
||||||
|
temp_zip.replace(zip_path)
|
||||||
|
temp_zip = None # Mark as moved so we don't delete it
|
||||||
finally:
|
finally:
|
||||||
|
# Clean up temp zip if it wasn't moved
|
||||||
|
if temp_zip and temp_zip.exists():
|
||||||
|
try:
|
||||||
|
temp_zip.unlink(missing_ok=True)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
# Clean up list file, with retry in case 7z still has it open
|
# Clean up list file, with retry in case 7z still has it open
|
||||||
if list_file_path and list_file_path.exists():
|
if list_file_path and list_file_path.exists():
|
||||||
for attempt in range(3):
|
for attempt in range(3):
|
||||||
@@ -270,20 +302,29 @@ def zip_sequence(seq_dir: Path, zip_path: Path) -> None:
|
|||||||
pass
|
pass
|
||||||
return
|
return
|
||||||
|
|
||||||
# Use zipfile (ZIPPER_TYPE == "zip" or fallback)
|
# Use zipfile (only if ZIPPER_TYPE == "zip")
|
||||||
from zipfile import ZIP_DEFLATED, ZIP_STORED, ZipFile
|
if ZIPPER_TYPE == "zip":
|
||||||
|
from zipfile import ZIP_DEFLATED, ZIP_STORED, ZipFile
|
||||||
|
|
||||||
zip_path.parent.mkdir(parents=True, exist_ok=True)
|
zip_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
if COMPRESSION_LEVEL <= 0:
|
if COMPRESSION_LEVEL <= 0:
|
||||||
compression = ZIP_STORED
|
compression = ZIP_STORED
|
||||||
zip_kwargs = {}
|
zip_kwargs = {}
|
||||||
else:
|
else:
|
||||||
compression = ZIP_DEFLATED
|
compression = ZIP_DEFLATED
|
||||||
zip_kwargs = {"compresslevel": COMPRESSION_LEVEL}
|
zip_kwargs = {"compresslevel": COMPRESSION_LEVEL}
|
||||||
|
|
||||||
with ZipFile(zip_path, "w", compression=compression, **zip_kwargs) as archive:
|
with ZipFile(zip_path, "w", compression=compression, **zip_kwargs) as archive:
|
||||||
for file_path in iter_sequence_files(seq_dir):
|
for file_path in iter_sequence_files(seq_dir):
|
||||||
archive.write(file_path, arcname=file_path.relative_to(seq_dir).as_posix())
|
archive.write(file_path, arcname=file_path.relative_to(seq_dir).as_posix())
|
||||||
|
return
|
||||||
|
|
||||||
|
# Unknown ZIPPER_TYPE - fail with clear error
|
||||||
|
raise RuntimeError(
|
||||||
|
f"Unsupported ZIPPER_TYPE: {ZIPPER_TYPE!r}. "
|
||||||
|
f"Expected '7z' or 'zip'. "
|
||||||
|
f"Config zipper value: {CONFIG.get('zipper', 'not set')!r}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def expand_sequence(zip_path: Path, seq_state: dict) -> None:
|
def expand_sequence(zip_path: Path, seq_state: dict) -> None:
|
||||||
@@ -294,7 +335,10 @@ def expand_sequence(zip_path: Path, seq_state: dict) -> None:
|
|||||||
|
|
||||||
if ZIPPER_TYPE == "7z":
|
if ZIPPER_TYPE == "7z":
|
||||||
if SEVEN_Z_EXE is None:
|
if SEVEN_Z_EXE is None:
|
||||||
raise RuntimeError("7z extraction requested but 7z executable not found in PATH")
|
raise RuntimeError(
|
||||||
|
"7z extraction requested but 7z executable not found in PATH. "
|
||||||
|
"Please install 7z or set zipper to 'zip' in config.json"
|
||||||
|
)
|
||||||
cmd = [
|
cmd = [
|
||||||
SEVEN_Z_EXE,
|
SEVEN_Z_EXE,
|
||||||
"x",
|
"x",
|
||||||
@@ -302,12 +346,29 @@ def expand_sequence(zip_path: Path, seq_state: dict) -> None:
|
|||||||
str(zip_path),
|
str(zip_path),
|
||||||
f"-o{target_dir}",
|
f"-o{target_dir}",
|
||||||
]
|
]
|
||||||
subprocess.run(cmd, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
result = subprocess.run(
|
||||||
else:
|
cmd,
|
||||||
|
check=False,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
if result.returncode != 0:
|
||||||
|
error_msg = result.stderr.strip() if result.stderr else "Unknown error"
|
||||||
|
if result.stdout:
|
||||||
|
error_msg += f"\nstdout: {result.stdout.strip()}"
|
||||||
|
raise RuntimeError(f"7z extraction failed: {error_msg}")
|
||||||
|
elif ZIPPER_TYPE == "zip":
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
|
|
||||||
with ZipFile(zip_path, "r") as archive:
|
with ZipFile(zip_path, "r") as archive:
|
||||||
archive.extractall(target_dir)
|
archive.extractall(target_dir)
|
||||||
|
else:
|
||||||
|
raise RuntimeError(
|
||||||
|
f"Unsupported ZIPPER_TYPE: {ZIPPER_TYPE!r}. "
|
||||||
|
f"Expected '7z' or 'zip'. "
|
||||||
|
f"Config zipper value: {CONFIG.get('zipper', 'not set')!r}"
|
||||||
|
)
|
||||||
|
|
||||||
for entry in seq_state.get("files", []):
|
for entry in seq_state.get("files", []):
|
||||||
file_path = target_dir / entry["path"]
|
file_path = target_dir / entry["path"]
|
||||||
@@ -336,11 +397,34 @@ def run_zip(worker_count: int, *, verbose: bool) -> int:
|
|||||||
if not seq_state["files"]:
|
if not seq_state["files"]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Get the target archive path (will be .7z if ZIPPER_TYPE is "7z")
|
||||||
zip_path = archive_path_for(seq_dir)
|
zip_path = archive_path_for(seq_dir)
|
||||||
state_path = state_path_for(zip_path)
|
state_path = state_path_for(zip_path)
|
||||||
stored_state = load_state(state_path)
|
|
||||||
|
|
||||||
|
# Check if we need to upgrade from .zip to .7z
|
||||||
|
old_zip_path = None
|
||||||
|
if ZIPPER_TYPE == "7z":
|
||||||
|
# Check if an old .zip file exists
|
||||||
|
old_zip_path = zip_path.with_suffix(".zip")
|
||||||
|
if old_zip_path.exists():
|
||||||
|
# Check if the old .zip's metadata matches current state
|
||||||
|
old_state_path = state_path_for(old_zip_path)
|
||||||
|
old_stored_state = load_state(old_state_path)
|
||||||
|
if not state_changed(seq_state, old_stored_state):
|
||||||
|
# Old .zip is up to date, skip conversion
|
||||||
|
continue
|
||||||
|
# Old .zip is out of date, will be replaced with .7z
|
||||||
|
|
||||||
|
# Check if the target archive (e.g., .7z) already exists and is up to date
|
||||||
|
stored_state = load_state(state_path)
|
||||||
if not state_changed(seq_state, stored_state):
|
if not state_changed(seq_state, stored_state):
|
||||||
|
# Target archive is up to date, but we might still need to clean up old .zip
|
||||||
|
if old_zip_path and old_zip_path.exists():
|
||||||
|
# Old .zip exists but we have a newer .7z, remove the old one
|
||||||
|
old_zip_path.unlink(missing_ok=True)
|
||||||
|
old_state_path = state_path_for(old_zip_path)
|
||||||
|
if old_state_path.exists():
|
||||||
|
old_state_path.unlink(missing_ok=True)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
work_items.append((seq_dir, zip_path, state_path, seq_state))
|
work_items.append((seq_dir, zip_path, state_path, seq_state))
|
||||||
@@ -394,18 +478,21 @@ def run_expand(worker_count: int, *, verbose: bool) -> int:
|
|||||||
|
|
||||||
work_items: list[tuple[Path, dict]] = []
|
work_items: list[tuple[Path, dict]] = []
|
||||||
|
|
||||||
for zip_path in ARCHIVE_ROOT.rglob("*.zip"):
|
# Look for both .zip and .7z archives
|
||||||
state_path = state_path_for(zip_path)
|
archive_patterns = ["*.zip", "*.7z"]
|
||||||
seq_state = load_state(state_path)
|
for pattern in archive_patterns:
|
||||||
if seq_state is None:
|
for zip_path in ARCHIVE_ROOT.rglob(pattern):
|
||||||
log("expand", f"Skipping {zip_path} (missing metadata)")
|
state_path = state_path_for(zip_path)
|
||||||
continue
|
seq_state = load_state(state_path)
|
||||||
|
if seq_state is None:
|
||||||
|
log("expand", f"Skipping {zip_path} (missing metadata)")
|
||||||
|
continue
|
||||||
|
|
||||||
target_dir = sequence_dir_for(zip_path)
|
target_dir = sequence_dir_for(zip_path)
|
||||||
if current_state(target_dir) == seq_state:
|
if current_state(target_dir) == seq_state:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
work_items.append((zip_path, seq_state))
|
work_items.append((zip_path, seq_state))
|
||||||
|
|
||||||
if not work_items:
|
if not work_items:
|
||||||
log("expand", "Working folders already match archives; nothing to expand.")
|
log("expand", "Working folders already match archives; nothing to expand.")
|
||||||
@@ -437,19 +524,22 @@ def cleanup_orphan_archives(*, verbose: bool) -> int:
|
|||||||
|
|
||||||
removed: list[Path] = []
|
removed: list[Path] = []
|
||||||
|
|
||||||
for zip_path in ARCHIVE_ROOT.rglob("*.zip"):
|
# Look for both .zip and .7z archives
|
||||||
seq_dir = sequence_dir_for(zip_path)
|
archive_patterns = ["*.zip", "*.7z"]
|
||||||
if seq_dir.exists():
|
for pattern in archive_patterns:
|
||||||
continue
|
for zip_path in ARCHIVE_ROOT.rglob(pattern):
|
||||||
|
seq_dir = sequence_dir_for(zip_path)
|
||||||
|
if seq_dir.exists():
|
||||||
|
continue
|
||||||
|
|
||||||
rel = zip_path.relative_to(ARCHIVE_ROOT)
|
rel = zip_path.relative_to(ARCHIVE_ROOT)
|
||||||
log("zip", f"Removing orphan archive {rel}", verbose_only=True, verbose=verbose)
|
log("zip", f"Removing orphan archive {rel}", verbose_only=True, verbose=verbose)
|
||||||
|
|
||||||
zip_path.unlink(missing_ok=True)
|
zip_path.unlink(missing_ok=True)
|
||||||
state_path = state_path_for(zip_path)
|
state_path = state_path_for(zip_path)
|
||||||
if state_path.exists():
|
if state_path.exists():
|
||||||
state_path.unlink()
|
state_path.unlink()
|
||||||
removed.append(zip_path)
|
removed.append(zip_path)
|
||||||
|
|
||||||
if not removed:
|
if not removed:
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user