From local testing, resources do seem to be automatically deleted when note history is disabled (though as per @HarSel's comment perhaps there's a bug that causes them not to be deleted in some cases).
The amount of time they're kept still seems to be based on the Keep note history for (days)
setting (even when note history is off).
Keep note history for (days)
setting (even when note history is off).Summary of testing:
- Started Joplin 2.14.9 (dev mode)
- Created a note
- Attached an image
- Disabled note history
- Set "keep note history for (days)" to 1
- Copied the resource ID (eb1119675151422eb060c62ed84c8bc1)
- Closed Joplin
- Re-opened Joplin
- Opened the development tools and searched for
ResourceService::deleteOrphanResources
- Waited about 30 seconds
- Saw
ResourceService::deleteOrphanResources
with no resources - Closed Joplin
- Set the system date/time to Jan 30 2024 @ 2:40 PM (several weeks in the future)
- DANGER: Avoid doing this if Joplin syncs to anything or has notes you care about — Joplin seems to use timestamps for sync, so this may lead to sync issues/data loss.
- Deleted the resource from the note and closed Joplin
- Set the date to February 29th and re-opened Joplin
- Opened the development tools and searched for
ResourceService::deleteOrphanResources
- Waited roughly 30 seconds
- Saw
ResourceService::deleteOrphanResources: eb1119675151422eb060c62ed84c8bc1
in the log - Checked "Note attachments" for the resource (it's gone!)
As such, setting Keep note history for (days)
to 1
and disabling note history should delete unlinked attachments after roughly one day.
Just before resources are deleted, a line starting with ResourceService::deleteOrphanResources:
should be added to the log that includes which resources were deleted.
See also:
- Code that handles orphaned resource deletion
- Observe that the code references the
revisionService.ttlDays
setting (which seems to have a minimum value of 1, despite being changeable to0
in settings).
- Observe that the code references the
- Code that schedules orphaned resource deletion
- Orphaned resources should be deleted 30 seconds after opening the application, then every four hours.
- Original post with similar information to the above