Homepage    |    GitHub    |    API    |    FAQ

Does Joplin do any garbage collection with deleted resources?

Over the last few weeks I've been running various tests with Joplin to see how it performs with lots of notes over more long term usage. In the process I've noticed something interesting I could see causing a potential issue.

When you add an image or another file that isn't text to a note, Joplin creates a separate resource file and assigns it an id gets stored in the SQL database.

This is fine since markdown doesn't natively support integrated images, and doing so would require creating some kind of non-standard (proprietary) function. However, if you then sync the file with a remote server (Dropbox, Nextcloud, etc.), then delete the reference to the file in your note, or delete the note entirely. While the reference is gone, the image still remains in your local joplin-desktop resources folder, and doesn't appear to ever be removed from the remote server.

I would think that with the number of resources some notes can contain (depending on the user) and the number that are naturally picked up by the web clipper. If images and other resources are never deleted, this could create unnecessary problems with storage space on the user's device, as well as cloud sync target of choice. I don't know much about SQL, but I would think that enough of this would also slow down reading and writing to the database, particularly on weak/low power devices such as mobile.

Does Joplin have any kind of "Garbage Collection" function that periodically checks to see if resources are referenced in any of the users notes and deletes ones that are never or no longer referenced?

Please check your note history settings:
Note History: Joplin - an open source note taking and to-do application with synchronisation capabilities

Maximum database size is far above what can be used effectively in a note app Implementation Limits For SQLite (Severeal terabytes of data in the SQLLite database).

Ah! I didn't think about note history, that would make sense. What about the sync target? Since each client can be set to have a different amount of time to keep note history, how is that handled?

From the doc:

IMPORTANT : Please note that since all the revisions are synced across all devices, it means these settings are kind of global. So for example, if on one device you set it to keep revisions for 30 days, and on another to 100 days, the revisions older than 30 days will be deleted

Guess I missed that, thank you very much!