Major rework of piwigo_refresh.pl to also support updating already synced photos

Fix folder sync function was also updating files
This commit is contained in:
2019-05-24 16:56:43 +02:00
parent 484d83c318
commit 178cf76fdb
2 changed files with 162 additions and 80 deletions

View File

@@ -1,5 +1,15 @@
#!/bin/bash
# syncronise piwigo database
# piwirefresh.sh [OPTION] [CATEGORY] [RECURSIVE]
# OPTION
# --meta_all|-m : including already synchronised photos
# CATEGORY
# number != 0 : limit scan to only one category
# find number in dev tools on piwigos' site_update site
# RECURSIVE
# 0 or 1 : wheter to scan CATEGORY recursively
# Get script working directory
# (when called from a different directory)
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
@@ -25,6 +35,15 @@ if [ -z $mounted ] ; then
exit 1;
fi
metaAll=0
case "$1" in
--meta_all|-m) # including already synchronised photos
metaAll=1
shift
;;
esac
if [ "$1" != "" ] && [ "$2" != "" ]
then
piwiRefreshCatId=$1
@@ -32,7 +51,7 @@ then
fi
perl -w /root/script/piwigo_refresh.pl \
perl -w $WDIR/piwigo_refresh.pl \
--base_url="${piwiRefreshUrl}" \
--site=${piwiRefreshSiteId} \
--user="${piwiRefreshUser}" \
@@ -40,8 +59,12 @@ perl -w /root/script/piwigo_refresh.pl \
--directory="${piwiRefreshSite}" \
--caddie=0 \
--privacy_level=${piwiRefreshPrivacy} \
--meta_all=${metaAll} \
--cat=${piwiRefreshCatId} \
--subcat=${piwiRefreshSubCatId}
ENDTIME=$(date +%s)
echo "Refresh took: $((($ENDTIME - $STARTTIME)/60)) minutes"
# Don't calculate runtime yet
# TODO there seems to be a timeout for the refresh; it always returns after 6 minutes
# although php process of piwigo is still running
#echo "Refresh took: $((($ENDTIME - $STARTTIME)/60)) minutes"