laurent22 / joplin

Joplin - the privacy-focused note taking app with sync capabilities for Windows, macOS, Linux, Android and iOS.
https://joplinapp.org
Other
46.37k stars 5.04k forks source link

Joplin crashes on startup with read-only-related error #11457

Open personalizedrefrigerator opened 1 day ago

personalizedrefrigerator commented 1 day ago

Operating system

Windows

Joplin version

3.1.24 and 3.1.23

Desktop version info

No response

Current behaviour

From the forum:

An error occurred: Fatal error:

Cannot change or delete a read-only item: e3ce90472d9f4e8b95acff6a437d0cac
   at checkIfItemCanBeChanged
(C:\Users\Pa\AppData\Local\Programs\Joplin\resources\app.asar\node_modules\@joplin\lib\....:15)
   at checkIfItemsCanBeChanged
(C:\Users\Pa\AppData\Local\Programs\Joplin\resources\app.asar\node_modules\@joplin\lib\....:45)
   at async Note.batchDelete
(C:\Users\Pa\AppData\Local\Programs\Joplin\resources\app.asar\node_modules\@joplin\lib\....:17)
   at async permanentlyDeleteOldItems
(C:\Users\Pa\AppData\Local\Programs\Joplin\resources\app.asar\node_modules\@joplin\lib\....:5)
   at async setupAutoDeletion
...

This happens when Joplin attempts to remove old read-only items from the trash on startup.

In particular, the error is happening here:

https://github.com/laurent22/joplin/blob/24542ca4048baba7a2eb4cef32fe2d5e0139e9bc/packages/lib/services/trash/permanentlyDeleteOldItems.ts#L23

permanentlyDeleteOldItems calls Note.batchDelete, which calls BaseItem.batchDelete, which calls checkIfItemsCanBeChanged:

https://github.com/laurent22/joplin/blob/24542ca4048baba7a2eb4cef32fe2d5e0139e9bc/packages/lib/models/BaseItem.ts#L311

This then throws a JoplinError because one of the items is read-only:

https://github.com/laurent22/joplin/blob/24542ca4048baba7a2eb4cef32fe2d5e0139e9bc/packages/lib/models/utils/readOnly.ts#L45

Expected behaviour

Joplin should not try crash on startup.

Logs

No response

personalizedrefrigerator commented 1 day ago

Update: This may not affect mobile — setupAutoDeletion is currently only called in BaseApplication, which is not used on mobile.