# 'is\_associated' in note\_resource = '0' / (at what time orphaned files are detectable)

**URL:** <https://discourse.joplinapp.org/t/is-associated-in-note-resource-0-at-what-time-orphaned-files-are-detectable/4443>\
**Category:** Development\
**Created:** [25 November 2019 20:30 UTC](https://discourse.joplinapp.org/t/is-associated-in-note-resource-0-at-what-time-orphaned-files-are-detectable/4443 "2019-11-25T20:30:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrick-atgithub](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/patrick-atgithub/32/1741_2.png) [@patrick-atgithub](https://discourse.joplinapp.org/u/patrick-atgithub)\
**Post date:** [25 November 2019 20:30 UTC](https://discourse.joplinapp.org/t/is-associated-in-note-resource-0-at-what-time-orphaned-files-are-detectable/4443/1 "2019-11-25T20:30:30Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![tessus](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/tessus/32/13_2.png) [@tessus](https://discourse.joplinapp.org/u/tessus)\
**Post date:** [26 November 2019 00:09 UTC](https://discourse.joplinapp.org/t/is-associated-in-note-resource-0-at-what-time-orphaned-files-are-detectable/4443/2 "2019-11-26T00:09:37Z")

</div>

This thread has a lot of info.

> [@Is there a way to force Joplin to run the unused resources cleanup?](https://discourse.joplinapp.org/t/is-there-a-way-to-force-joplin-to-run-the-unused-resources-cleanup/3758):
>
> Does anyone know how to force Joplin to run the unused resources cleanup routine? I just used the web clipper to clip a webpage with almost 1000 icons. I thought they were unicode characters and I wanted a reference note so I could cut and paste but it turns out they are svg files :(. I was able to quickly catch the mistake and deleted the note immediately but there are almost 1000 stranded attachment resources now that remain. They are easy to identify with timestamps. I know that Joplin doe…

---

<div class="post-metadata">

**Author:** ![patrick-atgithub](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/patrick-atgithub/32/1741_2.png) [@patrick-atgithub](https://discourse.joplinapp.org/u/patrick-atgithub)\
**Post date:** [26 November 2019 14:32 UTC](https://discourse.joplinapp.org/t/is-associated-in-note-resource-0-at-what-time-orphaned-files-are-detectable/4443/3 "2019-11-26T14:32:44Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![patrick-atgithub](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/patrick-atgithub/32/1741_2.png) [@patrick-atgithub](https://discourse.joplinapp.org/u/patrick-atgithub)\
**Post date:** [26 November 2019 18:27 UTC](https://discourse.joplinapp.org/t/is-associated-in-note-resource-0-at-what-time-orphaned-files-are-detectable/4443/4 "2019-11-26T18:27:40Z")

</div>

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 …

---

<div class="post-metadata">

**Author:** ![laurent](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@laurent](https://discourse.joplinapp.org/u/laurent)\
**Post date:** [26 November 2019 20:13 UTC](https://discourse.joplinapp.org/t/is-associated-in-note-resource-0-at-what-time-orphaned-files-are-detectable/4443/5 "2019-11-26T20:13:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![patrick-atgithub](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/patrick-atgithub/32/1741_2.png) [@patrick-atgithub](https://discourse.joplinapp.org/u/patrick-atgithub)\
**Post date:** [27 November 2019 09:06 UTC](https://discourse.joplinapp.org/t/is-associated-in-note-resource-0-at-what-time-orphaned-files-are-detectable/4443/6 "2019-11-27T09:06:31Z")

</div>

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
