Compare commits
2 Commits
b140883b90
...
12afbdf343
| Author | SHA1 | Date | |
|---|---|---|---|
| 12afbdf343 | |||
| b8418641e1 |
File diff suppressed because it is too large
Load Diff
@@ -29,6 +29,14 @@ if "%WINPATH%"=="" (
|
|||||||
exit /b
|
exit /b
|
||||||
)
|
)
|
||||||
|
|
||||||
|
REM Convert Windows path to NAS path and pre-seed eaDir_tmp from @eaDir on NAS
|
||||||
|
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'"
|
||||||
|
|
||||||
REM Run psthumbgen.py
|
REM Run psthumbgen.py
|
||||||
python psthumbgen.py --directory "%WINPATH%"
|
python psthumbgen.py --directory "%WINPATH%"
|
||||||
goto END
|
goto END
|
||||||
@@ -50,17 +58,14 @@ echo DEBUG: WINPATH = %WINPATH%
|
|||||||
echo DEBUG: RELPATH = %RELPATH%
|
echo DEBUG: RELPATH = %RELPATH%
|
||||||
echo DEBUG: NASPATH = %NASPATH%
|
echo DEBUG: NASPATH = %NASPATH%
|
||||||
echo.
|
echo.
|
||||||
|
REM Ensure nascleanup.sh exists on NAS (upload + fix line endings), then run it
|
||||||
REM SSH cleanup commands (run separately)
|
echo Uploading nascleanup.sh to NAS and running cleanup...
|
||||||
echo Running SSH cleanup commands...
|
if not exist "%~dp0nascleanup.sh" (
|
||||||
echo.
|
echo ERROR: nascleanup.sh not found next to this batch file.
|
||||||
echo Please run these commands manually on your NAS:
|
goto END
|
||||||
echo.
|
)
|
||||||
echo ssh nathan@hydra
|
ssh Hydra "cat > ~/nascleanup.sh" < "%~dp0nascleanup.sh"
|
||||||
echo find "%NASPATH%" -type d -name '@eaDir' -exec rm -rf '{}' \;
|
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%\"'"
|
||||||
echo find "%NASPATH%" -type d -name 'eaDir_tmp' -exec bash -c 'mv "$0" "${0%%/*}/@eaDir"' {} \;
|
|
||||||
echo.
|
|
||||||
echo Press any key when done...
|
|
||||||
goto END
|
goto END
|
||||||
|
|
||||||
:BOTH
|
:BOTH
|
||||||
@@ -71,9 +76,6 @@ if "%WINPATH%"=="" (
|
|||||||
exit /b
|
exit /b
|
||||||
)
|
)
|
||||||
|
|
||||||
REM Run psthumbgen.py
|
|
||||||
python psthumbgen.py --directory "%WINPATH%"
|
|
||||||
|
|
||||||
REM Convert Windows path to NAS path
|
REM Convert Windows path to NAS path
|
||||||
set "RELPATH=%WINPATH:~3%"
|
set "RELPATH=%WINPATH:~3%"
|
||||||
set "RELPATH=%RELPATH:\=/%"
|
set "RELPATH=%RELPATH:\=/%"
|
||||||
@@ -84,16 +86,22 @@ echo DEBUG: RELPATH = %RELPATH%
|
|||||||
echo DEBUG: NASPATH = %NASPATH%
|
echo DEBUG: NASPATH = %NASPATH%
|
||||||
echo.
|
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'"
|
||||||
|
|
||||||
|
REM Run psthumbgen.py
|
||||||
|
python psthumbgen.py --directory "%WINPATH%"
|
||||||
|
|
||||||
REM SSH cleanup commands (run separately)
|
REM SSH cleanup commands (run separately)
|
||||||
echo Running SSH cleanup commands...
|
REM Ensure nascleanup.sh exists on NAS (upload + fix line endings), then run it
|
||||||
echo.
|
echo Uploading nascleanup.sh to NAS and running cleanup...
|
||||||
echo Please run these commands manually on your NAS:
|
if not exist "%~dp0nascleanup.sh" (
|
||||||
echo.
|
echo ERROR: nascleanup.sh not found next to this batch file.
|
||||||
echo ssh nathan@hydra
|
goto END
|
||||||
echo find "%NASPATH%" -type d -name '@eaDir' -exec rm -rf '{}' \;
|
)
|
||||||
echo find "%NASPATH%" -type d -name 'eaDir_tmp' -exec bash -c 'mv "$0" "${0%%/*}/@eaDir"' {} \;
|
ssh Hydra "cat > ~/nascleanup.sh" < "%~dp0nascleanup.sh"
|
||||||
echo.
|
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%\"'"
|
||||||
echo Press any key when done...
|
|
||||||
goto END
|
goto END
|
||||||
|
|
||||||
:FIX_ONEDRIVE
|
:FIX_ONEDRIVE
|
||||||
|
|||||||
51
extract_eadir_to_tmp.sh
Normal file
51
extract_eadir_to_tmp.sh
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo "Usage: $0 <directory_path>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
TARGET_DIR="$1"
|
||||||
|
|
||||||
|
if [ ! -d "$TARGET_DIR" ]; then
|
||||||
|
echo "Error: '$TARGET_DIR' is not a directory"
|
||||||
|
exit 1
|
||||||
|
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
|
||||||
|
PARENT_DIR="$(dirname "$EADIR")"
|
||||||
|
|
||||||
|
# Each immediate subdir under @eaDir corresponds to a source filename
|
||||||
|
find "$EADIR" -mindepth 1 -maxdepth 1 -type d -print0 | while IFS= read -r -d '' ENTRY; do
|
||||||
|
BASENAME="$(basename "$ENTRY")"
|
||||||
|
DEST_DIR="$PARENT_DIR/eaDir_tmp/$BASENAME"
|
||||||
|
|
||||||
|
mkdir -p "$DEST_DIR"
|
||||||
|
|
||||||
|
# Copy without overwriting existing files in eaDir_tmp
|
||||||
|
for F in \
|
||||||
|
SYNOVIDEO_VIDEO_SCREENSHOT.jpg \
|
||||||
|
SYNOPHOTO_THUMB_XL.jpg \
|
||||||
|
SYNOPHOTO_THUMB_B.jpg \
|
||||||
|
SYNOPHOTO_THUMB_M.jpg \
|
||||||
|
SYNOPHOTO_THUMB_PREVIEW.jpg \
|
||||||
|
SYNOPHOTO_THUMB_S.jpg; do
|
||||||
|
if [ -f "$ENTRY/$F" ] && [ ! -f "$DEST_DIR/$F" ]; then
|
||||||
|
cp "$ENTRY/$F" "$DEST_DIR/$F"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "=== Done. Existing thumbnails copied into eaDir_tmp where available. ==="
|
||||||
|
|
||||||
|
|
||||||
@@ -15,13 +15,22 @@ echo "=== Enhanced Synology Thumbnail Cleanup ==="
|
|||||||
echo "Target directory: $TARGET_DIR"
|
echo "Target directory: $TARGET_DIR"
|
||||||
|
|
||||||
# 1. Stop indexing services temporarily
|
# 1. Stop indexing services temporarily
|
||||||
echo "Stopping indexing services..."
|
echo "Stopping indexing services (best effort)..."
|
||||||
sudo synoservicectl --stop synoindexd 2>/dev/null || true
|
if command -v synoservicectl >/dev/null 2>&1; then
|
||||||
sudo synoservicectl --stop pkgctl-SynoFinder 2>/dev/null || true
|
synoservicectl --stop synoindexd 2>/dev/null || true
|
||||||
|
synoservicectl --stop pkgctl-SynoFinder 2>/dev/null || true
|
||||||
|
elif command -v systemctl >/dev/null 2>&1; then
|
||||||
|
systemctl stop synoindexd 2>/devnull || true
|
||||||
|
systemctl stop pkgctl-SynoFinder 2>/dev/null || true
|
||||||
|
else
|
||||||
|
echo " -> Service control unavailable; skipping"
|
||||||
|
fi
|
||||||
|
|
||||||
# 2. Clear indexing queue to prevent regeneration
|
# 2. Clear indexing queue to prevent regeneration
|
||||||
echo "Clearing indexing queue..."
|
echo "Clearing indexing queue (if accessible)..."
|
||||||
sudo rm -f /var/spool/syno_indexing_queue* 2>/dev/null || true
|
if [ -w /var/spool ]; then
|
||||||
|
rm -f /var/spool/syno_indexing_queue* 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
# 3. Dry-run check (see what @eaDir directories exist)
|
# 3. Dry-run check (see what @eaDir directories exist)
|
||||||
echo "=== Existing @eaDir directories ==="
|
echo "=== Existing @eaDir directories ==="
|
||||||
@@ -33,17 +42,17 @@ find "$TARGET_DIR" -type d -name '@eaDir' -exec rm -rf '{}' \; 2>/dev/null || tr
|
|||||||
|
|
||||||
# 5. Rename eaDir_tmp to @eaDir (your custom thumbnails)
|
# 5. Rename eaDir_tmp to @eaDir (your custom thumbnails)
|
||||||
echo "=== Installing custom thumbnails ==="
|
echo "=== Installing custom thumbnails ==="
|
||||||
find "$TARGET_DIR" -type d -name 'eaDir_tmp' -exec bash -c 'mv "$0" "${0%/*}/@eaDir"' {} \;
|
# 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"; mv "$d" "${d%/*}/@eaDir"' _ {} \; 2>/dev/null || true
|
||||||
|
|
||||||
# 6. Protect custom thumbnails with read-only permissions
|
# 6. Protect custom thumbnails with read-only permissions
|
||||||
echo "=== Protecting custom thumbnails ==="
|
|
||||||
find "$TARGET_DIR" -type d -name '@eaDir' -exec chmod 555 '{}' \;
|
|
||||||
find "$TARGET_DIR" -path '*/@eaDir/*' -type f -exec chmod 444 '{}' \;
|
|
||||||
|
|
||||||
# 7. Create .noindex files to hint indexing services to avoid these directories
|
|
||||||
echo "=== Adding indexing exclusion hints ==="
|
echo "=== Adding indexing exclusion hints ==="
|
||||||
find "$TARGET_DIR" -type d -name '@eaDir' -exec touch '{}/.noindex' \;
|
find "$TARGET_DIR" -type d -name '@eaDir' -exec sh -c 'touch "$1/.noindex" 2>/dev/null || true' _ {} \;
|
||||||
|
|
||||||
|
# 7. Protect custom thumbnails with read-only permissions (after .noindex)
|
||||||
|
echo "=== Protecting custom thumbnails ==="
|
||||||
|
find "$TARGET_DIR" -type d -name '@eaDir' -exec chmod 555 '{}' \; 2>/dev/null || true
|
||||||
|
find "$TARGET_DIR" -path '*/@eaDir/*' -type f -exec chmod 444 '{}' \; 2>/dev/null || true
|
||||||
|
|
||||||
echo "=== Cleanup complete! ==="
|
echo "=== Cleanup complete! ==="
|
||||||
echo "Note: Indexing services stopped. They may restart automatically."
|
echo "Note: If indexing was stopped and needs restarting, use DSM UI or your NAS service tools."
|
||||||
echo "Run 'sudo synoservicectl --start synoindexd' if you need to re-enable indexing."
|
|
||||||
Reference in New Issue
Block a user