Tessus' Joplin Cleanup Script for Orphan Resources Nuked Everything

I originally posted this here a few days ago. It should be relevant here.

They [orphaned resources] should be automatically deleted:

joplin/packages/lib/services/ResourceService.ts at ee18271f9b8bd9a4ce48891ac1963d3b323a8f66 · laurent22/joplin · GitHub

From the above code, it looks like they are deleted based on the "Keep note history for (days)" setting (if the resource's "last_seen_time" is more than that number of days ago).

From local tests (inspecting the value of revisionService.ttlDays), this seems to be the case even when note history is disabled and have a minimum value of 1 day.

The task that deletes unlinked resources should run 30 seconds after startup, then every 4 hours. When it runs, ResourceService::deleteOrphanResources followed by the IDs of the deleted resources should be added to the log.

In short:

Changing the "Keep note history for" setting should change how long unlinked resources are kept (regardless of whether note history is enabled or not).

For example, changing "Keep note history for" to "1", then restarting Joplin (closing with File > Quit) and waiting 30 seconds should delete unlinked resources that were last linked more than a day ago.