'is_associated' in note_resource = '0' / (at what time orphaned files are detectable)

I am kind of curious when exactly ‘is_associated’ in ’
note_resources in the database changes from ‘1’ to ‘0’ / the resource is marked as unassociated. For example:

  • I create a note with an image: then image appears in resource_dir
  • I delete the image in the note: image stays in resource_dir and is_associated = 1 in database

After some time (?) / closing joplin (?) / syncing (?) it changes to ‘0’ (while the image stays in the resource_dir).

Never found out exactly when it gets unassociated. Does anybody know ?

This thread has a lot of info.

I read all 29 replies twice and did not find an answer when exatly is_associated changes from 1 to 0…

laurents reply:
“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.”
also doesn’t really help…

ok … so heres what I found out :
(btw this is all about at what time orphaned files can be detected …and removed by tools and skripts)

a delete/associate/ophaned file test for you to check on your own(note history not enabled):

  • make note
  • drop image into note (image will appear in resource_dir)
  • delete image (image will stay in resource as orphane)
  • wait until image gets marked in database as is_associated = 0 (see below…)
  • remove with skript / tool

now the question is: when does joplin mark the orphaned file as is_asscociated = 0 and detectable as orphane ?:

does not work:
(will NOT update database to unlinked/unassociated status after deletion = orphaned files not detectable):

  • wait 10 min
  • sync
  • restart
  • restart + sync

works:
(is_associated changes from 1 to 0 after deletion = detectable as orphaned file:)

  • restart + sync + wait about 10 secs …

I prefer to give the usual warning - those are internal stuff in Joplin and it’s better not to build scripts around it because the behaviour might not be exactly as you think, and it might change from one version to the next.

Especially for things like deleting items I personally wouldn’t rely on this. There’s no unit tests to verify what you’re doing so you can’t be sure about much.

1 Like

agreed, fiddling around with internal stuff isn’t a good idea … although if you’re using the joplin api for deleting resource ids it feels rather safe … of course this is just a workaround until joplin will do it itsself (no pun intended, I think joplin is AWESOME !). And thank you laurent for being around replying

1 Like