tessus / joplin-scripts

scripts for Joplin
53 stars 3 forks source link

disabled note history prevents deletion? #5

Closed ahxxm closed 10 months ago

ahxxm commented 10 months ago

the script respects note history settings by default with this check

KEEP=`sqlite3 $DB "select value from settings where key = 'revisionService.ttlDays'"`
if [ -z "$KEEP" ]; then

However when I disabled note history, and execute the SQL statement in sqlite, it returns empty result, but the script goes into the next line anyway, thus I need to wait for 90 days to delete "just orphaned" resources

I used zsh by the way, does -z behave the same in both shells?

tessus commented 10 months ago

Hmm, it seems that the setting is no longer stored in the database, but the settings.json file. So this is the reason why it sets it to 90.

However, even if you disable your notes history, the revisionService.ttlDays won't be changed. Only the revisionService.enabled will be set to false.

Let's say you had your notes history at 10 days. Then you decided to turn off that feature. The notes that had revisions are still composed of the note + the revisions. Joplin will stitch them together and present it to you as one note. So if you were to delete resources that are referenced in any of those "revision" files, you'd be missing data.

This is why setting this to 0 can cause data loss.

I don't know, whether the note revisions will ever be combined to a single note again (and the revision files are purged) internally, when you turn off revisions. This would be a question for @laurent22

I would have to change the script to retrieve the data from the settings.json file. It won't be a be big change, but it will create an additional dependency. jq will be required on the system where you run the script.

I used zsh by the way, does -z behave the same in both shells?

The script still uses bash, so it doesn't matter. But yes, they behave the same.

tessus commented 10 months ago

fixed by e86aa3045543fa8688f4b1ca3fbefce7cd43dbf7