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

Operating system

Windows

Joplin version

2.14.8

What issue do you have?

“Resources that are not attached to any note will be automatically deleted in accordance to the Note History settings”, according to https:// joplinapp . org /help/apps/attachments

“If a resource is associated with any note, is_associated is 1, it it’s not is_associated is 0. From the moment is_associated is 0, a timer starts and after x days the resource is deleted”, as described in https:// discourse . joplinapp . org /t/is-there-a-way-to-force-joplin-to-run-the-unused-resources-cleanup/3758/23

When one clips a web-page or its fragment using Web Clipper, some irrelevant ad banners (pictures) end up in the newly created note. One then manually deletes such pictures, usually a few per note.
Do such attachments (pictures), no longer associated with any note, still get automatically deleted someday, if Note History feature is disabled, and therefore a cleanup routine that deletes old notes from the Note History may not be required to run?

Thank you.

No. I've always had history turned off and still have images floating around that have been there for years. I have to delete them manually and clipping a Web page with dozens of images can make for a fairly tedious task. Delete image, scroll to next one, delete that, repeat.

1 Like

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

Whenever I add a new device (phone/tablet etc.) there are 3 images that get created as part of the new "Welcome" notebook on that device. These get synced to the target even if the "Welcome" notebook was deleted before the sync. History on my PC (and the mobile) is always disabled yet these 3 images are permanent until I go in via "Note Attachments" and delete them manually. History setting makes no difference, those are never removed automatically nor are images I myself attached to notes and then deleted the notes. Images seem to remain until I do an export-uninstall-delete-install-import cycle. Could partly explain why I have only 2600 notes but must fetch 35,000 resources when I sync a new device for the first time.

I have tried this both ways, setting history to 1 day with history on and the same with history off. Images are still there weeks later no matter the setting. I have to do an export-import routine every month to keep the clutter under control.

One possibility is that Joplin deletes resources locally then re-downloads them from the sync target.

Checking the log[1] for lines starting with ResourceService::deleteOrphanResources: (then followed by a resource ID) could help show whether Joplin is trying to delete resources at all.


  1. ~/.config/joplin-desktop/log.txt on Linux and MacOS, I think C:\Users\UserName\.config\joplin-desktop\log.txt on Windows. ↩︎

1 Like

@personalizedrefriger thanks a lot for the very helpful explanation!

I searched the %userprofile%\.config\joplin-desktop\log.txt for “ResourceService::deleteOrphanResources”.

It seems it is indeed irrelevant whether “Enable note history” checkbox is turned on or off, because I have always had it turned off.

Indeed, what matters is the value of “Keep note history for (days)”.

When I set it from “90” (default value) to “0”, upon next launch Joplin detected 600+ orphaned resources and deleted them.

As I have been using Joplin for less than 90 days, no orphaned resources were deleted via “ResourceService::deleteOrphanResources” procedure until I lowered the threshold - there had been many identical empty log entries:

"ResourceService::deleteOrphanResources:", "[]"

1 Like

I first set it back to the 90 day default and waited a few days. I identified 6 files I could be sure were orphans (2 each of AllClients.png, SubNotebooks.png and WebClipper.png) and reset the history back down to 1 day. After 48 hours I checked again and they were still there so I set history back down to zero and waited two days until a few minutes ago. Those files are still there.

Perhaps these are considered "system" files and are thus untouchable or the note history length has no effect. Since I have never, in years and years, seen these orphaned resources automatically deleted I assumed the "Keep note history" to be a less than effective method of reducing the clutter and relied upon the manual method of exporting everything, wiping all traces of Joplin everywhere, importing everything and re-syncing 8 devices, a job that usually takes a few days.

What happens if you set it to 0 in settings then? It it treated as the same as 1 or ignored as invalid?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.