Skip to content

Commit

Permalink
Merge pull request #177 from ospring/fixBackToHome
Browse files Browse the repository at this point in the history
Avoid useless rescan : Detect if local lib files have changed after sync
  • Loading branch information
fsantini authored Apr 5, 2024
2 parents 8f1e461 + 8cdbc71 commit b571607
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
4 changes: 4 additions & 0 deletions local_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
SERVICE=$1
TEST_DELETED=$2


TestFiles=("ulysses.epub" "01/ulysses.epub" "01/ulysses01.epub" "02/ulysses.epub" "02/ulysses02.epub")
sha1=d07c5da10d4666766d1b796ba420cffca0ac440c
TestSubdirs=false
Expand Down Expand Up @@ -110,5 +111,8 @@ do
fi
done

#relaunch sync to test when no change has to be made
src/usr/local/kobocloud/get.sh TEST

# if we reached here, we are good
exit 0
23 changes: 20 additions & 3 deletions src/usr/local/kobocloud/get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ then
fi
fi

#list file in lib dir before sync
lib_list_before=`ls -lnR --full-time "$Lib"`
echo "$lib_list_before"

while read url || [ -n "$url" ]; do
echo "Reading $url"
if echo "$url" | grep -q '^#'; then
Expand Down Expand Up @@ -94,10 +98,23 @@ if grep -q "^REMOVE_DELETED$" $UserConfig; then
recursiveUpdateFiles
fi

if [ "$TEST" = "" ]
#list file in lib dir after sync
lib_list_after=`ls -lnR --full-time "$Lib"`
echo "$lib_list_after"

#compare filelist before and after
if [ "$lib_list_after" = "$lib_list_before" ]
then
# Use NickelDBus for library refresh
/usr/bin/qndb -t 3000 -s pfmDoneProcessing -m pfmRescanBooksFull
echo "No Library Change. skipping rescan"
else
echo "Library has changed, rescan needed"


if [ "$TEST" = "" ]
then
# Use NickelDBus for library refresh
/usr/bin/qndb -t 3000 -s pfmDoneProcessing -m pfmRescanBooksFull
fi
fi

rm "$Logs/index" >/dev/null 2>&1
Expand Down
4 changes: 2 additions & 2 deletions src/usr/local/kobocloud/getRemoteFile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ if [ ! -z "$dropboxPath" ] && [ "$dropboxPath" != "-" ]; then
curlCommand="$CURL -X POST --header \"Authorization: Bearer $user\" --header \"Dropbox-API-Arg: {\\\"path\\\": \\\"$dropboxPath\\\"}\""
fi

echo "Download:" $curlCommand -k --silent -C - -L --create-dirs -o \"$localFile\" \"$linkLine\" -v
echo "Download:" $curlCommand -k --silent -C - -L --create-dirs --remote-time -o \"$localFile\" \"$linkLine\" -v

eval $curlCommand -k --silent -C - -L --create-dirs -o \"$localFile\" \"$linkLine\" -v 2>$outputFileTmp
eval $curlCommand -k --silent -C - -L --create-dirs --remote-time -o \"$localFile\" \"$linkLine\" -v 2>$outputFileTmp
status=$?
echo "Status: $status"
echo "Output: "
Expand Down

0 comments on commit b571607

Please sign in to comment.