handle nested dirs
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -46,13 +46,13 @@
|
||||
"last_updated": "2026-03-22T18:11:22Z"
|
||||
},
|
||||
"88555ca4-9c88-4bcf-825f-dd19b19b7145": {
|
||||
"user_message_count": 43,
|
||||
"agent_message_count": 425,
|
||||
"user_message_count": 50,
|
||||
"agent_message_count": 592,
|
||||
"start_timestamp": "2026-03-21T13:01:32-06:00",
|
||||
"end_timestamp": "2026-03-21T13:01:32-06:00",
|
||||
"markdown_size_bytes": 348634,
|
||||
"markdown_size_bytes": 461149,
|
||||
"provider": "cursoride",
|
||||
"last_updated": "2026-03-22T18:56:15Z"
|
||||
"last_updated": "2026-03-22T19:25:16Z"
|
||||
},
|
||||
"8a226504-a2e0-4b10-b083-a609486034c7": {
|
||||
"user_message_count": 9,
|
||||
|
||||
+5
-2
@@ -191,8 +191,11 @@ goto END
|
||||
REM Print ssh Hydra command to wipe @eaDir when NAS cleanup failed (matches NASPATH from pasted R:\ path).
|
||||
:PRINT_HYDRA_CLEAR_EADIR
|
||||
if "%NASPATH%"=="" goto :eof
|
||||
echo %MAG%To clear locked @eaDir on Hydra: ssh in first, then run:%RST%
|
||||
echo %BLD%%YLW% sudo rm -rf "%NASPATH%/@eaDir"%RST%
|
||||
echo %MAG%To clear locked @eaDir on Hydra: ssh in first.%RST%
|
||||
echo %GRY%Permission denied lines above name nested paths ^(e.g. editDesc, gameplay^).%RST%
|
||||
echo %GRY%Clear every @eaDir under the SAME folder you passed to nascleanup ^(NASPATH below^),%RST%
|
||||
echo %GRY%not only the subpath from the first error line.%RST%
|
||||
echo %BLD%%YLW% sudo find "%NASPATH%" -depth -type d -name '@eaDir' -exec sudo rm -rf {} +%RST%
|
||||
goto :eof
|
||||
|
||||
REM Remove folder-level @eaDir on the pasted Windows path (same files as NAS over SMB).
|
||||
|
||||
@@ -20,8 +20,8 @@ fi
|
||||
echo "=== Extracting @eaDir thumbnails to eaDir_tmp ==="
|
||||
echo "Target: $TARGET_DIR"
|
||||
|
||||
# Only TARGET_DIR/@eaDir (not nested .../@eaDir/.../@eaDir from bad prior runs; those hit chmod 555 parents)
|
||||
find "$TARGET_DIR" -mindepth 1 -maxdepth 1 -type d -name '@eaDir' -print0 | while IFS= read -r -d '' EADIR; do
|
||||
# Every .../@eaDir under TARGET (e.g. TARGET/@eaDir and TARGET/gameplay/@eaDir). Skip paths inside eaDir_tmp.
|
||||
find "$TARGET_DIR" -type d -name '@eaDir' ! -path '*/eaDir_tmp/*' -print0 | while IFS= read -r -d '' EADIR; do
|
||||
PARENT_DIR="$(dirname "$EADIR")"
|
||||
|
||||
# Each immediate subdir under @eaDir corresponds to a source filename
|
||||
|
||||
+42
-31
@@ -28,6 +28,38 @@ flatten_indexer_layout() {
|
||||
done
|
||||
}
|
||||
|
||||
# Copy one thumbgen tree: PARENT/eaDir_tmp -> PARENT/@eaDir (psthumbgen uses per-folder eaDir_tmp).
|
||||
promote_one_eadir_tmp() {
|
||||
local EADIR_TMP="$1"
|
||||
local PARENT TARGET_AT SRC_JPG DST_JPG
|
||||
PARENT="$(dirname "$EADIR_TMP")"
|
||||
TARGET_AT="$PARENT/@eaDir"
|
||||
[ -d "$EADIR_TMP" ] || return 0
|
||||
chmod -R 755 "$EADIR_TMP" 2>/dev/null || true
|
||||
find "$EADIR_TMP" -type f -exec chmod 644 '{}' \; 2>/dev/null || true
|
||||
echo " -> Flattening eaDir_tmp (indexer may have added .../<file>/@eaDir/) before copy: $EADIR_TMP"
|
||||
flatten_indexer_layout "$EADIR_TMP"
|
||||
echo " -> Replacing $EADIR_TMP -> $TARGET_AT"
|
||||
SRC_JPG=$(find "$EADIR_TMP" -type f -name 'SYNO*.jpg' 2>/dev/null | wc -l | tr -d '[:space:]')
|
||||
rm -rf "$TARGET_AT"
|
||||
mkdir -p "$TARGET_AT"
|
||||
if ! cp -R "$EADIR_TMP/." "$TARGET_AT/"; then
|
||||
echo "ERROR: eaDir_tmp -> @eaDir copy failed (see cp messages above)."
|
||||
exit 1
|
||||
fi
|
||||
echo " -> Flattening @eaDir after copy (same layout fix)"
|
||||
flatten_indexer_layout "$TARGET_AT"
|
||||
DST_JPG=$(find "$TARGET_AT" -type f -name 'SYNO*.jpg' 2>/dev/null | wc -l | tr -d '[:space:]')
|
||||
if [ "$SRC_JPG" -gt 0 ] && [ "$DST_JPG" -ne "$SRC_JPG" ]; then
|
||||
echo "ERROR: Promote incomplete: $DST_JPG SYNO*.jpg in @eaDir vs $SRC_JPG in eaDir_tmp (expected equal)."
|
||||
exit 1
|
||||
fi
|
||||
chmod -R 755 "$EADIR_TMP" 2>/dev/null || true
|
||||
find "$EADIR_TMP" -type f -exec chmod u+w '{}' \; 2>/dev/null || true
|
||||
find "$EADIR_TMP" -type d -exec chmod u+w '{}' \; 2>/dev/null || true
|
||||
rm -rf "$EADIR_TMP" 2>/dev/null || sudo -n rm -rf "$EADIR_TMP" 2>/dev/null || true
|
||||
}
|
||||
|
||||
echo "=== Enhanced Synology Thumbnail Cleanup ==="
|
||||
echo "Target directory: $TARGET_DIR"
|
||||
|
||||
@@ -77,39 +109,18 @@ find "$TARGET_DIR" -path '*/@eaDir/*' -type f -exec chmod 644 '{}' \; 2>/dev/nul
|
||||
# Now remove them (2>/dev/null: races when parents disappear mid-find)
|
||||
find "$TARGET_DIR" -type d -name '@eaDir' -exec rm -rf '{}' \; 2>/dev/null || true
|
||||
|
||||
# 5. Promote only TARGET_DIR/eaDir_tmp -> TARGET_DIR/@eaDir (thumbgen layout; not nested */eaDir_tmp)
|
||||
# 5. Promote every .../eaDir_tmp -> .../@eaDir (thumbgen writes eaDir_tmp next to each video folder, not only TARGET_DIR/eaDir_tmp)
|
||||
echo "=== Installing custom thumbnails ==="
|
||||
EADIR_TMP="$TARGET_DIR/eaDir_tmp"
|
||||
if [ -d "$EADIR_TMP" ]; then
|
||||
chmod -R 755 "$EADIR_TMP" 2>/dev/null || true
|
||||
find "$EADIR_TMP" -type f -exec chmod 644 '{}' \; 2>/dev/null || true
|
||||
echo " -> Flattening eaDir_tmp (indexer may have added .../<file>/@eaDir/) before copy"
|
||||
flatten_indexer_layout "$EADIR_TMP"
|
||||
TARGET_AT="$TARGET_DIR/@eaDir"
|
||||
echo " -> Replacing $EADIR_TMP -> $TARGET_AT"
|
||||
SRC_JPG=$(find "$EADIR_TMP" -type f -name 'SYNO*.jpg' 2>/dev/null | wc -l | tr -d '[:space:]')
|
||||
rm -rf "$TARGET_AT"
|
||||
mkdir -p "$TARGET_AT"
|
||||
if ! cp -R "$EADIR_TMP/." "$TARGET_AT/"; then
|
||||
echo "ERROR: eaDir_tmp -> @eaDir copy failed (see cp messages above)."
|
||||
exit 1
|
||||
fi
|
||||
echo " -> Flattening @eaDir after copy (same layout fix)"
|
||||
flatten_indexer_layout "$TARGET_AT"
|
||||
DST_JPG=$(find "$TARGET_AT" -type f -name 'SYNO*.jpg' 2>/dev/null | wc -l | tr -d '[:space:]')
|
||||
if [ "$SRC_JPG" -gt 0 ] && [ "$DST_JPG" -ne "$SRC_JPG" ]; then
|
||||
echo "ERROR: Promote incomplete: $DST_JPG SYNO*.jpg in @eaDir vs $SRC_JPG in eaDir_tmp (expected equal)."
|
||||
exit 1
|
||||
fi
|
||||
chmod -R 755 "$EADIR_TMP" 2>/dev/null || true
|
||||
find "$EADIR_TMP" -type f -exec chmod u+w '{}' \; 2>/dev/null || true
|
||||
find "$EADIR_TMP" -type d -exec chmod u+w '{}' \; 2>/dev/null || true
|
||||
rm -rf "$EADIR_TMP" 2>/dev/null || sudo -n rm -rf "$EADIR_TMP" 2>/dev/null || true
|
||||
else
|
||||
echo " -> No $EADIR_TMP; skipping install step"
|
||||
INSTALL_ANY=0
|
||||
while IFS= read -r -d '' EADIR_TMP; do
|
||||
INSTALL_ANY=1
|
||||
promote_one_eadir_tmp "$EADIR_TMP"
|
||||
done < <(find "$TARGET_DIR" -type d -name 'eaDir_tmp' -print0)
|
||||
if [ "$INSTALL_ANY" -eq 0 ]; then
|
||||
echo " -> No eaDir_tmp under $TARGET_DIR; skipping install step"
|
||||
fi
|
||||
echo "=== Removing stray nested eaDir_tmp directories ==="
|
||||
find "$TARGET_DIR" -mindepth 2 -type d -name 'eaDir_tmp' -exec rm -rf '{}' \; 2>/dev/null || true
|
||||
echo "=== Removing any leftover eaDir_tmp directories ==="
|
||||
find "$TARGET_DIR" -type d -name 'eaDir_tmp' -exec rm -rf '{}' \; 2>/dev/null || true
|
||||
|
||||
# 6. Protect custom thumbnails with read-only permissions
|
||||
echo "=== Adding indexing exclusion hints ==="
|
||||
|
||||
@@ -85,6 +85,17 @@ def _print_ffmpeg(msg):
|
||||
print(f"{_ANSI_GREEN}{msg}{_ANSI_RST}")
|
||||
|
||||
|
||||
def _ffmpeg_first_for_gameplay_path(path):
|
||||
"""Under ...\\gameplay\\, Shell GetThumbnail often fails and Icaros cache misses; go straight to FFmpeg."""
|
||||
if not _ffmpeg_enabled():
|
||||
return False
|
||||
try:
|
||||
p = os.path.normpath(path).replace("/", "\\").lower()
|
||||
except Exception:
|
||||
return False
|
||||
return "\\gameplay\\" in p
|
||||
|
||||
|
||||
def find_files(dir):
|
||||
# Only process formats that Synology doesn't handle well
|
||||
# Exclude common images (jpg, png, gif, etc.) since NAS handles them fine
|
||||
@@ -145,6 +156,10 @@ def ensure_directory_exists(path):
|
||||
|
||||
def create_video_thumbnails(source_path, dest_dir):
|
||||
"""Generate video thumbnails: Windows Shell (Icaros-backed) first, FFmpeg fallback."""
|
||||
if _ffmpeg_first_for_gameplay_path(source_path):
|
||||
_print_ffmpeg(f"Using FFmpeg directly (gameplay subtree): {source_path}")
|
||||
create_video_thumbnails_ffmpeg(source_path, dest_dir)
|
||||
return
|
||||
# Try Windows thumbnail extraction first (leverages Icaros provider when present)
|
||||
windows_thumb = extract_windows_thumbnail(source_path)
|
||||
if windows_thumb:
|
||||
|
||||
Reference in New Issue
Block a user