From 2549a298a4b52122efd353fea2591a6f5f234249 Mon Sep 17 00:00:00 2001 From: mwiegand Date: Wed, 23 Feb 2022 18:04:06 +0100 Subject: [PATCH] nextcloud picsort: faster, apperently --- .../nextcloud-picsort/files/nextcloud-picsort | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/bundles/nextcloud-picsort/files/nextcloud-picsort b/bundles/nextcloud-picsort/files/nextcloud-picsort index 269f9e5..e12fa22 100644 --- a/bundles/nextcloud-picsort/files/nextcloud-picsort +++ b/bundles/nextcloud-picsort/files/nextcloud-picsort @@ -2,8 +2,12 @@ USER="$1" SOURCEPATH="/var/lib/nextcloud/$1/files/$2" -DESTINATIONPATH="/var/lib/nextcloud/$1/files/$3" -UNSORTABLEPATH="/var/lib/nextcloud/$1/files/$4" + +REL_DEST_PATH="/$1/files/$3" +ABS_DEST_PATH="/var/lib/nextcloud/$1/files/$3" + +REL_UNSORTABLE_PATH="/$1/files/$4" +ABS_UNSORTABLE_PATH="/var/lib/nextcloud/$1/files/$4" echo "STARTING..." @@ -19,7 +23,7 @@ for f in `find "$SOURCEPATH" -iname *.PNG -o -iname *.JPG -o -iname *.CR2 -o -in if ! echo "$DATE" | grep "Create Date" >/dev/null then RELPATH=$(realpath --relative-to="$SOURCEPATH" "$f") - DIRNAME=$(dirname "$UNSORTABLEPATH/$RELPATH") + DIRNAME=$(dirname "$ABS_UNSORTABLE_PATH/$RELPATH") echo "UNSORTABLE: $f" mkdir -p "$DIRNAME" mv "$f" "$DIRNAME" @@ -39,7 +43,7 @@ for f in `find "$SOURCEPATH" -iname *.PNG -o -iname *.JPG -o -iname *.CR2 -o -in else RAW="" fi - FILE="$DESTINATIONPATH/$YEAR-$MONTH/$RAW$YEAR$MONTH$DAY"-"$HOUR$MINUTE$SECOND"_"$HASH"."$EXT" + FILE="$ABS_DEST_PATH/$YEAR-$MONTH/$RAW$YEAR$MONTH$DAY"-"$HOUR$MINUTE$SECOND"_"$HASH"."$EXT" echo "DESTINATION: $FILE" mkdir -p "$(dirname "$FILE")" mv -v "$f" "$FILE" @@ -49,12 +53,13 @@ done if [ "$SCAN" == "TRUE" ]; then echo "SCANNING..." # find "$SOURCEPATH/"* -type d -empty -delete >> /var/echo/nc-picsort.echo # nextcloud app bug when deleting folders - chown -R www-data:www-data "$DESTINATIONPATH" - chown -R www-data:www-data "$UNSORTABLEPATH" - chmod -R 770 "$DESTINATIONPATH" - chmod -R 770 "$UNSORTABLEPATH" - sudo -u www-data php /opt/nextcloud/occ files:scan "$USER" - sudo -u www-data php /opt/nextcloud/occ preview:generate-all "$USER" + chown -R www-data:www-data "$ABS_DEST_PATH" + chown -R www-data:www-data "$ABS_UNSORTABLE_PATH" + chmod -R 770 "$ABS_DEST_PATH" + chmod -R 770 "$ABS_UNSORTABLE_PATH" + sudo -u www-data php /opt/nextcloud/occ files:scan --path "$REL_UNSORTABLE_PATH" + sudo -u www-data php /opt/nextcloud/occ files:scan --path "$REL_DEST_PATH" + sudo -u www-data php /opt/nextcloud/occ preview:pre-generate fi echo "FINISH."