What if you delete the note B very fast (before syncing)?
The logic is the same in both cases - the resource will be deleted after x days, depending on the history settings.
But the resource is still in use!
When does note_resources
update? I added some attachments to some notes but that table doesn't contain them. They are present in resources
but running
select * from note_resources
where note_id = mynoteid
Doesn't return anything, nor does looking for resource_id
with the new attachment ids (from the resource
table).
Or is it only on sync, which my dev env isn't doing right now.
Yes I mean only orphaned resources are auto-deleted. If they are still in use they aren't deleted.
That is the issue we are attempting to replicate as it seems non-orphaned resources are being inappropriately deleted, if the steps in question can be replicated.
30 seconds after startup, and then once every 4 hours when the app is running - https://github.com/laurent22/joplin/blob/8a65bb581826e3cce7b97b268782293a5cfe07ff/packages/lib/services/ResourceService.ts#L165
I don't have sync in the mix (still stuck on the dying laptop) but I followed steps I outlined here: Attachments lost after reorganizing notes - #13 by Daeraxa
and I can't replicate it.
- Created 3x notes with 3x unique resources
Resources
6d151c0f82344d7db5bcc88b3229ab71, res1.png
4122d98f032b45ba8ee35612f25f3dad, res2.png
d6637fd4d07c46c5b62249754e3693ff, res3.png
Notes
99dee02774bf45b6af08bddc63940e28
f0964d6d8f104cba9c626708cae818ee
1ee3b090415d49b4b741944bd895a3af
select * from note_resources
where resource_id in ('6d151c0f82344d7db5bcc88b3229ab71','4122d98f032b45ba8ee35612f25f3dad','d6637fd4d07c46c5b62249754e3693ff')
returns nothing.
- Restart Joplin to run resourceservice then rerun above query:
note_id, resource_id, is_associated
f0964d6d8f104cba9c626708cae818ee, 4122d98f032b45ba8ee35612f25f3dad, 1
99dee02774bf45b6af08bddc63940e28, 6d151c0f82344d7db5bcc88b3229ab71, 1
1ee3b090415d49b4b741944bd895a3af, d6637fd4d07c46c5b62249754e3693ff, 1
-
Move resources from notes 2 + 3 into note 1 then delete notes 2 + 3
- No change in
resources
ornote_resources
- No change in
-
Restart Joplin to run resourceservice + rerun query on
note_resources
note_id, resource_id, is_associated
f0964d6d8f104cba9c626708cae818ee, 4122d98f032b45ba8ee35612f25f3dad, 0
1ee3b090415d49b4b741944bd895a3af, 4122d98f032b45ba8ee35612f25f3dad, 1
99dee02774bf45b6af08bddc63940e28, 6d151c0f82344d7db5bcc88b3229ab71, 0
1ee3b090415d49b4b741944bd895a3af, 6d151c0f82344d7db5bcc88b3229ab71, 1
1ee3b090415d49b4b741944bd895a3af, d6637fd4d07c46c5b62249754e3693ff, 1
- Results are as I would expect with it noting the three resources associated to a single note and the other two notes with
is_associated = 0
So I'm guessing that if there is a bug here at all it is something to do with sync being thrown into the mix.
I wonder if this sequence of events possible and what would happen?
- I cut the resource link from note A
- Just as I'm about to paste it, the orphaned resource detector runs and marks the resource as orphaned.
- I paste the link into note B.
- Sync.
So, I added the resource back to the resource-folder and do the "Re-upload local data to sync target". It has last about 12 hours but no luck: The resource is not recognized by the note. Now, I have to add all missing resouces to the notes manually. And I found no way to display all notes with dead internal resource links.
In fact, you can scan all notes that contain links to invalid resources, and anyone can scan them using the following online tools @guckuck
https://joplin-utils.rxliuli.com/web/joplin-batch-web/#/notFoundResource
Also, I'm almost certain that there is some problem with the resource synchronization or auto-deletion mechanism, and today I scanned several notes and found that the resources were missing @laurent
Thanks, I tried that tool already but I get no notes with missing resources: "No reference to a failed resource was found".
Now, I had corrected all notes manually and sync all over all devices. I also create two new "summary-notes" and will be monitoring them closely.
I just fixed some bugs (just a few minutes before posting the last message), can you try again?
Force page refresh with ctrl+shift+r
I tried it a few seconds ago and now once again. Same result but mayby I found all notes with dead resource links.
Wait a minute, I try to print all the non-sensitive data in the console (note id and resource id and list of scanned link ids), can you send the data to me to do some testing later?
sample data
log.json (69.6 KB)
I don't get a log. I tried it with developer tools from firefox und from chrome.
Ah, you also need to click the button on the page