OliverHaag / pocketbook-apps

Apps for PocketBook Readers
GNU General Public License v3.0
16 stars 4 forks source link

deleted entries on nextcloud are not deleted on pocketbook reader #1

Open palegrand opened 4 years ago

palegrand commented 4 years ago

First things first: thank you very much for creating this app! is is exactly the 'missing link' to my nextcloud.

new entries are recognized and synced down to pocketbook. alas, deleted stuff on nextclud is not recognized and orphaned files remain on the pocketbook

I'm using an inkpad 3 pro with the newest firmware (6.0)

Any hint on how to solve this?

OliverHaag commented 4 years ago

Nice to hear it's useful for you :)

Files not on the server anymore are deleted as expected for me. The App will tell it didn't find updated ones first and after that it asks if it should delete the ones not on the server anymore. Could you recheck if you've got the latest version and waited for the message asking for deletion?

palegrand commented 4 years ago

last code from repo.

1) first synch works fine (maybe you should add to the doc that the local folder 'NextCloud' must exist)

2) add a book to the cloud sync works fine: shows one book to update and does the update nicely

3) delete the book from cloud sync works thru. reports 'no new book found' as expected  - but does never ask to delete anything after the script finishes the book from 2) is still available in local folder NextCloud

I installed the app and the cfg, but did not touch the language part (step 4 of your doc). it looks slightly different on my reader and I hope it does not influence the outcome

I added the following to the end of your script:

echo "$REMOTE_FILES_LIST" >"$LOCAL_DIR/debug_1_remote.txt" echo "$LOCAL_FILES_LIST" >"$LOCAL_DIR/debug_2_local.txt" echo "$UPDATED_FILES_LIST" >"$LOCAL_DIR/debug_3_update.txt" echo "$LOCAL_ONLY_FILES_LIST" >"$LOCAL_DIR/debug_4_localonly.txt" /ebrmain/bin/dialog 1 "" "Synchronisation abgeschlossen." @OK

local and remote lists are properly set.... but debug_4_localonly.txt is empty. looks like the problem is here: LOCAL_ONLY_FILES_LIST=$(echo "$LOCAL_FILES_LIST" | eval grep -vxF $(for FILE in $REMOTE_FILES_LIST; do echo -n " -e '$FILE'"; done))

Maybe you have a hint on how to proceed.

palegrand commented 4 years ago

*** remote: SchneierBruce - Cryptography Engineering Design Principles and Practical Applications.epub Schneier_Bruce - Schneier on Security.epub

*** local SchneierBruce - Cryptography Engineering Design Principles and Practical Applications.epub Schneier_Bruce - Schneier on Security.epub aliceDynamic.epub

localonly is empty.... I'd expect it to contain "aliceDynamic.epub"

palegrand commented 4 years ago

replacing the original LOCAL_ONLY_FILES_LIST=$(echo "$LOCAL_FILES_LIST" | eval grep -vxF $(for FILE in $REMOTE_FILES_LIST; do echo -n " -e '$FILE'"; done))

with LOCAL_ONLY_FILES_LIST=`diff --side-by-side --suppress-common-lines <(echo "$LOCAL_FILES_LIST") <(echo "$REMOTE_FILES_LIST")

does the trick (gives the correct list) on desktop linux (debian in my case). But it seems to be an invalid syntax on the pocketreader. I'm not used to the pocketreader variant yet...

OliverHaag commented 4 years ago

Didn't update my Inkpad 3 to 6.0 yet, will do this and check if they changed something. The reader only got a limited busybox environment, so I had to use some command constructs that may look unnecessarily complex.

palegrand commented 4 years ago

thank you! As I stated above I'm not used to the pocketbook.variant yet. For this reason I created a small test script on Debian (local.txt contains more entries than remote.txt):

#!/bin/bash
IFS=$'\n' 
REMOTE_FILES_LIST=$(cat "remote.txt")
LOCAL_FILES_LIST=$(cat "local.txt")
# original (results in an empty list on debian and pocketreader)
LOCAL_ONLY_FILES_LIST=$(echo "$LOCAL_FILES_LIST" | eval grep -vxF $(for FILE in $REMOTE_FILES_LIST; do echo -n " -e '$FILE'"; done))
# the following would work on debian -  but fails (syntax) on pocketbook
#LOCAL_ONLY_FILES_LIST=`diff  --side-by-side --suppress-common-lines  <(echo "$LOCAL_FILES_LIST")  <(echo "$REMOTE_FILES_LIST")`
echo "*** remote ***"
echo "$REMOTE_FILES_LIST"
echo "*** local ***"
echo "$LOCAL_FILES_LIST"
echo "*** diff ***"
echo "$LOCAL_ONLY_FILES_LIST"
echo "***"
palegrand commented 4 years ago

I found a solution that works well for me with firmware 6:

Replace Line 140 with

LOCAL_ONLY_FILES_LIST=$( echo  "${LOCAL_FILES_LIST}"$'\n'"${REMOTE_FILES_LIST}" | sort | uniq -u) 

after writing new files the new ones are local files,too. Insert line 133 (before fi):

# after updating we have the new files (hopefully) as local files available
LOCAL_FILES_LIST=$LOCAL_FILES_LIST$'\n'$UPDATED_FILES_LIST

there's a minor problem left when sync is cancelled: delete list contains entries that are only remotely available. Nothing bad happens, but the message is a bit confusing

OliverHaag commented 4 years ago

Should do as workaround but not really a fix. There is no v6 for the Inkpad 3 yet, will take a closer look as soon as it's out.