electron-userland / electron-json-storage

:package: Easily write and read user settings in Electron apps
1.43k stars 79 forks source link

Properly Deleting All Data #184

Open sorcerer-worker opened 2 years ago

sorcerer-worker commented 2 years ago

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.

jviotti commented 2 years ago

Hey there!

but given storage.clear() didn't work

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

sorcerer-worker commented 2 years ago

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.

jviotti commented 2 years ago

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?

sorcerer-worker commented 2 years ago

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.

jviotti commented 2 years ago

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