electron-json-storage icon indicating copy to clipboard operation
electron-json-storage copied to clipboard

Properly Deleting All Data

Open sorcerer-worker opened this issue 3 years ago • 5 comments

I read questions were answered through issues here.

I was wondering what the best practice for deleting information was for this library. I know of a workaround to delete data, but given storage.clear() didn't work when I was trying to reset all data stored on a Electron app. I'd like to know if there are more proper methods to doing stuff like this.

sorcerer-worker avatar Jul 29 '22 01:07 sorcerer-worker

Hey there!

but given storage.clear() didn't work

What do you mean by it didn't work? Did you get an exception?

jviotti avatar Jul 29 '22 13:07 jviotti

Hi! More so its like it didn't run. Its a really odd problem overall. And I'm really curious if there's a way outside of .clear() that's considered a alternative best practice.

sorcerer-worker avatar Jul 30 '22 00:07 sorcerer-worker

That seems strange. .clear() would just wipe out all the data files using rimraf: https://github.com/electron-userland/electron-json-storage/blob/master/lib/storage.js#L605.

What OS are you running this on? For example, I've seen similar weird problems due to anti-virus acquiring exclusive locks on files for scanning purposes, thus preventing any delete-action from taking place.

Also, what happens if you attempt to delete the specific JSON files using i.e. fs.unlink?

jviotti avatar Aug 01 '22 14:08 jviotti

Oh! I'm on my friend's Linux laptop he lent me. Its running Ubuntu. Also, that worked like a charm. Weird, but if that's the official alternative I'll take note.

sorcerer-worker avatar Aug 02 '22 19:08 sorcerer-worker

Interesting. Can you re-confirm that using .clear() does indeed not work on your machine, and no errors are reported?

jviotti avatar Aug 04 '22 13:08 jviotti