Do attachments (pictures) unattached to any note get deleted, if Note History is disabled?

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).

Summary of testing:

  1. Started Joplin 2.14.9 (dev mode)
  2. Created a note
  3. Attached an image
  4. Disabled note history
  5. Set "keep note history for (days)" to 1
  6. Copied the resource ID (eb1119675151422eb060c62ed84c8bc1)
  7. Closed Joplin
  8. Re-opened Joplin
  9. Opened the development tools and searched for ResourceService::deleteOrphanResources
  10. Waited about 30 seconds
  11. Saw ResourceService::deleteOrphanResources with no resources
  12. Closed Joplin
  13. 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.
  14. Deleted the resource from the note and closed Joplin
  15. Set the date to February 29th and re-opened Joplin
  16. Opened the development tools and searched for ResourceService::deleteOrphanResources
  17. Waited roughly 30 seconds
  18. Saw ResourceService::deleteOrphanResources: eb1119675151422eb060c62ed84c8bc1 in the log
  19. 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:

2 Likes