nascleanup + autoThumbs: flatten indexer layout, SMB rm, recursive tmp
This commit is contained in:
+1
-22
@@ -1,22 +1 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
|
||||
# Custom for Visual Studio
|
||||
*.cs diff=csharp
|
||||
*.sln merge=union
|
||||
*.csproj merge=union
|
||||
*.vbproj merge=union
|
||||
*.fsproj merge=union
|
||||
*.dbproj merge=union
|
||||
|
||||
# Standard to msysgit
|
||||
*.doc diff=astextplain
|
||||
*.DOC diff=astextplain
|
||||
*.docx diff=astextplain
|
||||
*.DOCX diff=astextplain
|
||||
*.dot diff=astextplain
|
||||
*.DOT diff=astextplain
|
||||
*.pdf diff=astextplain
|
||||
*.PDF diff=astextplain
|
||||
*.rtf diff=astextplain
|
||||
*.RTF diff=astextplain
|
||||
*.sh text eol=lf
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -45,6 +45,15 @@
|
||||
"provider": "cursoride",
|
||||
"last_updated": "2026-03-21T19:00:53Z"
|
||||
},
|
||||
"88555ca4-9c88-4bcf-825f-dd19b19b7145": {
|
||||
"user_message_count": 33,
|
||||
"agent_message_count": 323,
|
||||
"start_timestamp": "2026-03-21T13:01:32-06:00",
|
||||
"end_timestamp": "2026-03-21T13:01:32-06:00",
|
||||
"markdown_size_bytes": 297979,
|
||||
"provider": "cursoride",
|
||||
"last_updated": "2026-03-21T21:13:55Z"
|
||||
},
|
||||
"8a226504-a2e0-4b10-b083-a609486034c7": {
|
||||
"user_message_count": 8,
|
||||
"agent_message_count": 188,
|
||||
@@ -61,7 +70,7 @@
|
||||
"end_timestamp": "2025-06-25T22:09:21-06:00",
|
||||
"markdown_size_bytes": 38319,
|
||||
"provider": "cursoride",
|
||||
"last_updated": "2026-03-21T19:00:42Z"
|
||||
"last_updated": "2026-03-21T19:02:43Z"
|
||||
},
|
||||
"b90a47f3-3c59-4ca3-a099-690412afaab1": {
|
||||
"user_message_count": 7,
|
||||
|
||||
+43
-4
@@ -34,8 +34,13 @@ set "RELPATH=%WINPATH:~3%"
|
||||
set "RELPATH=%RELPATH:\=/%"
|
||||
set "NASPATH=/volume1/Hydra/%RELPATH%"
|
||||
|
||||
echo Seeding existing thumbnails on NAS (extract_eadir_to_tmp.sh)...
|
||||
ssh Hydra "bash -lc '~/extract_eadir_to_tmp.sh \"%NASPATH%\" || true'"
|
||||
echo Uploading extract_eadir_to_tmp.sh to NAS and seeding...
|
||||
if not exist "%~dp0extract_eadir_to_tmp.sh" (
|
||||
echo ERROR: extract_eadir_to_tmp.sh not found next to this batch file.
|
||||
goto END
|
||||
)
|
||||
ssh Hydra "cat > ~/extract_eadir_to_tmp.sh" < "%~dp0extract_eadir_to_tmp.sh"
|
||||
ssh Hydra "bash -lc 'if command -v dos2unix >/dev/null 2>&1; then dos2unix -f ~/extract_eadir_to_tmp.sh; else tr -d \"\r\" < ~/extract_eadir_to_tmp.sh > ~/extract_eadir_to_tmp.sh.tmp && mv ~/extract_eadir_to_tmp.sh.tmp ~/extract_eadir_to_tmp.sh; fi; chmod +x ~/extract_eadir_to_tmp.sh; ~/extract_eadir_to_tmp.sh \"%NASPATH%\" || true'"
|
||||
|
||||
REM Run psthumbgen.py
|
||||
python psthumbgen.py --directory "%WINPATH%"
|
||||
@@ -58,6 +63,7 @@ echo DEBUG: WINPATH = %WINPATH%
|
||||
echo DEBUG: RELPATH = %RELPATH%
|
||||
echo DEBUG: NASPATH = %NASPATH%
|
||||
echo.
|
||||
call :WIN_REMOVE_LOCAL_EADIR
|
||||
REM Ensure nascleanup.sh exists on NAS (upload + fix line endings), then run it
|
||||
echo Uploading nascleanup.sh to NAS and running cleanup...
|
||||
if not exist "%~dp0nascleanup.sh" (
|
||||
@@ -66,6 +72,7 @@ if not exist "%~dp0nascleanup.sh" (
|
||||
)
|
||||
ssh Hydra "cat > ~/nascleanup.sh" < "%~dp0nascleanup.sh"
|
||||
ssh Hydra "bash -lc 'if command -v dos2unix >/dev/null 2>&1; then dos2unix -f ~/nascleanup.sh; else tr -d \"\r\" < ~/nascleanup.sh > ~/nascleanup.sh.tmp && mv ~/nascleanup.sh.tmp ~/nascleanup.sh; fi; chmod +x ~/nascleanup.sh; ~/nascleanup.sh \"%NASPATH%\"'"
|
||||
call :WIN_REMOVE_LOCAL_EADIR_TMP
|
||||
goto END
|
||||
|
||||
:BOTH
|
||||
@@ -87,12 +94,20 @@ echo DEBUG: NASPATH = %NASPATH%
|
||||
echo.
|
||||
|
||||
REM Pre-seed eaDir_tmp from @eaDir on NAS before generation
|
||||
echo Seeding existing thumbnails on NAS (extract_eadir_to_tmp.sh)...
|
||||
ssh Hydra "bash -lc '~/extract_eadir_to_tmp.sh \"%NASPATH%\" || true'"
|
||||
echo Uploading extract_eadir_to_tmp.sh to NAS and seeding...
|
||||
if not exist "%~dp0extract_eadir_to_tmp.sh" (
|
||||
echo ERROR: extract_eadir_to_tmp.sh not found next to this batch file.
|
||||
goto END
|
||||
)
|
||||
ssh Hydra "cat > ~/extract_eadir_to_tmp.sh" < "%~dp0extract_eadir_to_tmp.sh"
|
||||
ssh Hydra "bash -lc 'if command -v dos2unix >/dev/null 2>&1; then dos2unix -f ~/extract_eadir_to_tmp.sh; else tr -d \"\r\" < ~/extract_eadir_to_tmp.sh > ~/extract_eadir_to_tmp.sh.tmp && mv ~/extract_eadir_to_tmp.sh.tmp ~/extract_eadir_to_tmp.sh; fi; chmod +x ~/extract_eadir_to_tmp.sh; ~/extract_eadir_to_tmp.sh \"%NASPATH%\" || true'"
|
||||
|
||||
REM Run psthumbgen.py
|
||||
python psthumbgen.py --directory "%WINPATH%"
|
||||
|
||||
REM Clear old @eaDir on the share via SMB (helps when NAS cp hits Permission denied on root-owned dirs)
|
||||
call :WIN_REMOVE_LOCAL_EADIR
|
||||
|
||||
REM SSH cleanup commands (run separately)
|
||||
REM Ensure nascleanup.sh exists on NAS (upload + fix line endings), then run it
|
||||
echo Uploading nascleanup.sh to NAS and running cleanup...
|
||||
@@ -102,6 +117,7 @@ if not exist "%~dp0nascleanup.sh" (
|
||||
)
|
||||
ssh Hydra "cat > ~/nascleanup.sh" < "%~dp0nascleanup.sh"
|
||||
ssh Hydra "bash -lc 'if command -v dos2unix >/dev/null 2>&1; then dos2unix -f ~/nascleanup.sh; else tr -d \"\r\" < ~/nascleanup.sh > ~/nascleanup.sh.tmp && mv ~/nascleanup.sh.tmp ~/nascleanup.sh; fi; chmod +x ~/nascleanup.sh; ~/nascleanup.sh \"%NASPATH%\"'"
|
||||
call :WIN_REMOVE_LOCAL_EADIR_TMP
|
||||
goto END
|
||||
|
||||
:FIX_ONEDRIVE
|
||||
@@ -147,5 +163,28 @@ echo 3. Your custom thumbnails should now have priority!
|
||||
echo.
|
||||
goto END
|
||||
|
||||
REM Remove folder-level @eaDir on the pasted Windows path (same files as NAS over SMB).
|
||||
:WIN_REMOVE_LOCAL_EADIR
|
||||
if "%WINPATH%"=="" goto :eof
|
||||
if exist "%WINPATH%\@eaDir" (
|
||||
echo Removing "%WINPATH%\@eaDir" via Windows ^(SMB share^)...
|
||||
rd /s /q "%WINPATH%\@eaDir" 2>nul
|
||||
if exist "%WINPATH%\@eaDir" (
|
||||
echo WARNING: Could not remove @eaDir; try PowerShell as admin or delete in Explorer.
|
||||
)
|
||||
)
|
||||
goto :eof
|
||||
|
||||
REM Remove every eaDir_tmp under pasted path (including subfolders e.g. gameplay\eaDir_tmp).
|
||||
:WIN_REMOVE_LOCAL_EADIR_TMP
|
||||
if "%WINPATH%"=="" goto :eof
|
||||
echo Removing all eaDir_tmp folders under "%WINPATH%" ^(recursive, SMB^)...
|
||||
if not exist "%~dp0remove_eadir_tmp_recursive.ps1" (
|
||||
echo ERROR: remove_eadir_tmp_recursive.ps1 not found next to this batch file.
|
||||
goto :eof
|
||||
)
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0remove_eadir_tmp_recursive.ps1" "%WINPATH%"
|
||||
goto :eof
|
||||
|
||||
:END
|
||||
pause
|
||||
@@ -3,7 +3,7 @@
|
||||
# Extract existing Synology thumbnails from @eaDir into eaDir_tmp so thumbgen skips regeneration
|
||||
# Usage: ./extract_eadir_to_tmp.sh /volume1/YourShare/path
|
||||
|
||||
set -euo pipefail
|
||||
set -uo pipefail
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: $0 <directory_path>"
|
||||
@@ -20,8 +20,8 @@ fi
|
||||
echo "=== Extracting @eaDir thumbnails to eaDir_tmp ==="
|
||||
echo "Target: $TARGET_DIR"
|
||||
|
||||
# For every @eaDir/<name> directory, copy known thumbnail files to eaDir_tmp/<name>
|
||||
find "$TARGET_DIR" -type d -name '@eaDir' -print0 | while IFS= read -r -d '' EADIR; do
|
||||
# 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
|
||||
PARENT_DIR="$(dirname "$EADIR")"
|
||||
|
||||
# Each immediate subdir under @eaDir corresponds to a source filename
|
||||
@@ -29,7 +29,7 @@ find "$TARGET_DIR" -type d -name '@eaDir' -print0 | while IFS= read -r -d '' EAD
|
||||
BASENAME="$(basename "$ENTRY")"
|
||||
DEST_DIR="$PARENT_DIR/eaDir_tmp/$BASENAME"
|
||||
|
||||
mkdir -p "$DEST_DIR"
|
||||
mkdir -p "$DEST_DIR" || continue
|
||||
|
||||
# Copy without overwriting existing files in eaDir_tmp
|
||||
for F in \
|
||||
@@ -48,4 +48,3 @@ done
|
||||
|
||||
echo "=== Done. Existing thumbnails copied into eaDir_tmp where available. ==="
|
||||
|
||||
|
||||
|
||||
+78
-18
@@ -11,17 +11,44 @@ fi
|
||||
|
||||
TARGET_DIR="$1"
|
||||
|
||||
# Merge synoindexd layout .../<file>/@eaDir/*.jpg into .../<file>/ (Synology Drive expects no inner @eaDir).
|
||||
flatten_indexer_layout() {
|
||||
local root="$1"
|
||||
[ -d "$root" ] || return 0
|
||||
find "$root" -mindepth 2 -type d -name '@eaDir' -print0 2>/dev/null | while IFS= read -r -d '' NEST; do
|
||||
PARENT="$(dirname "$NEST")"
|
||||
[ -d "$NEST" ] || continue
|
||||
for f in "$NEST"/*; do
|
||||
[ -e "$f" ] || continue
|
||||
base="$(basename "$f")"
|
||||
[ "$base" = "SYNOINDEX_MEDIA_INFO" ] && continue
|
||||
mv -f "$f" "$PARENT/" 2>/dev/null || true
|
||||
done
|
||||
rm -rf "$NEST" 2>/dev/null || true
|
||||
done
|
||||
}
|
||||
|
||||
echo "=== Enhanced Synology Thumbnail Cleanup ==="
|
||||
echo "Target directory: $TARGET_DIR"
|
||||
|
||||
# 1. Stop indexing services temporarily
|
||||
echo "Stopping indexing services (best effort)..."
|
||||
if command -v synoservicectl >/dev/null 2>&1; then
|
||||
synoservicectl --stop synoindexd 2>/dev/null || true
|
||||
synoservicectl --stop pkgctl-SynoFinder 2>/dev/null || true
|
||||
# Non-login SSH often has a minimal PATH; binary lives in /usr/syno/sbin
|
||||
if [ -x /usr/syno/sbin/synoservicectl ]; then
|
||||
SYNOCTL=/usr/syno/sbin/synoservicectl
|
||||
elif command -v synoservicectl >/dev/null 2>&1; then
|
||||
SYNOCTL=synoservicectl
|
||||
else
|
||||
SYNOCTL=""
|
||||
fi
|
||||
if [ -n "$SYNOCTL" ]; then
|
||||
"$SYNOCTL" --stop synoindexd 2>/dev/null || true
|
||||
"$SYNOCTL" --stop pkgctl-SynoFinder 2>/dev/null || true
|
||||
elif command -v systemctl >/dev/null 2>&1; then
|
||||
systemctl stop synoindexd 2>/dev/null || true
|
||||
systemctl stop pkgctl-SynoFinder 2>/dev/null || true
|
||||
# Plain `systemctl` as non-root usually fails silently; try sudo -n first (NOPASSWD).
|
||||
for u in synoindexd pkgctl-SynoFinder; do
|
||||
sudo -n systemctl stop "$u" 2>/dev/null || systemctl stop "$u" 2>/dev/null || true
|
||||
done
|
||||
else
|
||||
echo " -> Service control unavailable; skipping"
|
||||
fi
|
||||
@@ -38,26 +65,49 @@ find "$TARGET_DIR" -type d -name '@eaDir' -exec echo '{}' \;
|
||||
|
||||
# 4. Remove any existing @eaDir directories
|
||||
echo "=== Removing existing @eaDir directories ==="
|
||||
# Drop indexer sidecars first (often root-owned — passwordless sudo helps)
|
||||
if command -v sudo >/dev/null 2>&1; then
|
||||
sudo -n find "$TARGET_DIR" -name 'SYNOINDEX_MEDIA_INFO' \( -type f -o -type d \) -exec rm -rf '{}' \; 2>/dev/null || true
|
||||
fi
|
||||
find "$TARGET_DIR" -name 'SYNOINDEX_MEDIA_INFO' \( -type f -o -type d \) -exec chmod -R u+w '{}' \; 2>/dev/null || true
|
||||
find "$TARGET_DIR" -name 'SYNOINDEX_MEDIA_INFO' \( -type f -o -type d \) -exec rm -rf '{}' \; 2>/dev/null || true
|
||||
# First make them writable so we can remove them
|
||||
find "$TARGET_DIR" -type d -name '@eaDir' -exec chmod -R 755 '{}' \; 2>/dev/null || true
|
||||
find "$TARGET_DIR" -path '*/@eaDir/*' -type f -exec chmod 644 '{}' \; 2>/dev/null || true
|
||||
# Now remove them
|
||||
find "$TARGET_DIR" -type d -name '@eaDir' -exec rm -rf '{}' \; || true
|
||||
# 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. Rename eaDir_tmp to @eaDir (your custom thumbnails)
|
||||
# 5. Promote only TARGET_DIR/eaDir_tmp -> TARGET_DIR/@eaDir (thumbgen layout; not nested */eaDir_tmp)
|
||||
echo "=== Installing custom thumbnails ==="
|
||||
# Ensure eaDir_tmp contents are writable before renaming
|
||||
find "$TARGET_DIR" -type d -name 'eaDir_tmp' -exec chmod -R 755 '{}' \; 2>/dev/null || true
|
||||
find "$TARGET_DIR" -path '*/eaDir_tmp/*' -type f -exec chmod 644 '{}' \; 2>/dev/null || true
|
||||
# Use -depth so we process children before parents, and use $1 in bash -c for safety
|
||||
find "$TARGET_DIR" -depth -type d -name 'eaDir_tmp' -exec bash -c 'd="$1"; target="${d%/*}/@eaDir"; echo " -> Replacing $d"; rm -rf "$target"; mkdir -p "$target"; cp -a "$d/." "$target/"; rm -rf "$d"' _ {} \; || true
|
||||
# Remove any leftover eaDir_tmp directories (if rename failed)
|
||||
echo "=== Removing leftover eaDir_tmp directories ==="
|
||||
find "$TARGET_DIR" -type d -name 'eaDir_tmp' -exec rm -rf '{}' \; 2>/dev/null || true
|
||||
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"
|
||||
rm -rf "$TARGET_AT"
|
||||
mkdir -p "$TARGET_AT"
|
||||
cp -R "$EADIR_TMP/." "$TARGET_AT/"
|
||||
echo " -> Flattening @eaDir after copy (same layout fix)"
|
||||
flatten_indexer_layout "$TARGET_AT"
|
||||
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
|
||||
if ! rm -rf "$EADIR_TMP" 2>/dev/null; then
|
||||
echo " -> rm eaDir_tmp failed; retrying with sudo -n"
|
||||
sudo -n rm -rf "$EADIR_TMP" 2>/dev/null || echo " -> WARNING: remove stale eaDir_tmp manually: sudo rm -rf \"$EADIR_TMP\""
|
||||
fi
|
||||
else
|
||||
echo " -> No $EADIR_TMP; 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
|
||||
|
||||
# 6. Protect custom thumbnails with read-only permissions
|
||||
echo "=== Adding indexing exclusion hints ==="
|
||||
find "$TARGET_DIR" -type d -name '@eaDir' -exec sh -c 'touch "$1/.noindex" 2>/dev/null || true' _ {} \;
|
||||
find "$TARGET_DIR" -type d -name '@eaDir' -exec sh -c 'touch "$1/.noindex" 2>/dev/null || true' _ {} \; 2>/dev/null || true
|
||||
|
||||
# 7. Protect custom thumbnails with read-only permissions (after .noindex)
|
||||
echo "=== Protecting custom thumbnails ==="
|
||||
@@ -65,4 +115,14 @@ find "$TARGET_DIR" -type d -name '@eaDir' -exec chmod 555 '{}' \; 2>/dev/null ||
|
||||
find "$TARGET_DIR" -path '*/@eaDir/*' -type f -exec chmod 444 '{}' \; 2>/dev/null || true
|
||||
|
||||
echo "=== Cleanup complete! ==="
|
||||
echo "Note: If indexing was stopped and needs restarting, use DSM UI or your NAS service tools."
|
||||
echo "Restarting indexing services (best effort)..."
|
||||
if [ -n "$SYNOCTL" ]; then
|
||||
"$SYNOCTL" --start synoindexd 2>/dev/null || true
|
||||
"$SYNOCTL" --start pkgctl-SynoFinder 2>/dev/null || true
|
||||
elif command -v systemctl >/dev/null 2>&1; then
|
||||
for u in synoindexd pkgctl-SynoFinder; do
|
||||
sudo -n systemctl start "$u" 2>/dev/null || systemctl start "$u" 2>/dev/null || true
|
||||
done
|
||||
fi
|
||||
echo "Note: If indexing was stopped and needs restarting, use DSM UI or: sudo systemctl restart synoindexd"
|
||||
echo "If rm failed with Permission denied: delete @eaDir and eaDir_tmp on your pasted Windows path (SMB), or: sudo rm -rf ${TARGET_DIR}/eaDir_tmp ${TARGET_DIR}/@eaDir — then re-run option 3."
|
||||
+1
-1
@@ -825,7 +825,7 @@ def _build_icaros_index_map(cache_dir):
|
||||
|
||||
|
||||
def _lookup_icaros_index(cache_dir, file_path):
|
||||
"""Return (index, preferred_db_path) for file_path by inspecting Icaros_idx.icdb.
|
||||
r"""Return (index, preferred_db_path) for file_path by inspecting Icaros_idx.icdb.
|
||||
|
||||
Tries multiple strategies:
|
||||
1) Direct SQLite mapping (exact normalized full path match)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string] $Root
|
||||
)
|
||||
if (-not (Test-Path -LiteralPath $Root)) { exit 0 }
|
||||
$dirs = @(Get-ChildItem -LiteralPath $Root -Recurse -Directory -Filter 'eaDir_tmp' -ErrorAction SilentlyContinue |
|
||||
Sort-Object { $_.FullName.Length } -Descending)
|
||||
foreach ($d in $dirs) {
|
||||
try {
|
||||
Remove-Item -LiteralPath $d.FullName -Recurse -Force
|
||||
Write-Host "Removed: $($d.FullName)"
|
||||
} catch {
|
||||
Write-Host "Failed: $($d.FullName)"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user