refactor error handling and guidance
This commit is contained in:
+12
-7
@@ -87,18 +87,24 @@ if [ -d "$EADIR_TMP" ]; then
|
||||
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"
|
||||
cp -R "$EADIR_TMP/." "$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
|
||||
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
|
||||
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"
|
||||
fi
|
||||
@@ -124,5 +130,4 @@ elif command -v systemctl >/dev/null 2>&1; then
|
||||
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."
|
||||
echo "Note: If indexing was stopped and needs restarting, use DSM UI or: sudo systemctl restart synoindexd"
|
||||
Reference in New Issue
Block a user