Repository navigation
refactor(store): hold a weak reference on store - #3156
Legend-Master wants to merge 1 commit into
Conversation
Package Changes Through 6146142There are 21 changes which include dialog-js with minor, dialog with minor, log with minor, log-js with minor, localhost with patch, barcode-scanner with patch, barcode-scanner-js with patch, deep-link with patch, deep-link-js with patch, fs with patch, fs-js with patch, http with patch, http-js with patch, nfc with patch, nfc-js with patch, updater with minor, updater-js with minor, upload with minor, upload-js with minor, websocket with patch, websocket-js with patch Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
| let state = app.state::<StoreState<R>>(); | ||
| let mut stores = state.stores.lock().unwrap(); | ||
| if let Some(rid) = validate_resource_id(&app, stores.get_mut(&store.path)) { | ||
| let _ = app.resources_table().close(rid); |
There was a problem hiding this comment.
This is technically not safe since we didn't hold a lock through out and the resource id can be reused (tauri-apps/tauri#9272) ...
Option 3 of #3145 (comment)
We now always hold onto a weak reference on the
Storeuntil all the strong references to it get dropped, this ensures that we will only ever have 1Storefor a single path (except for when the user usescreate_new)This is similar to the implementation from the beginning of #1860
Not sure if it's worth it to be honest though