Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Clean up app data directories on uninstall #113

Closed
MarshallOfSound opened this issue Jul 4, 2016 · 18 comments
Closed

Request: Clean up app data directories on uninstall #113

MarshallOfSound opened this issue Jul 4, 2016 · 18 comments

Comments

@MarshallOfSound
Copy link
Member

Currently when you uninstall a Squirrel app it levaes behind it's AppData directory with quite a bit of data which means a uninstall -> reinstall is not a clean install.

It would be better if it deleted those AppData folders and their contents on uninstall as that would kind of be expected of an uninstall.

Trying to implement this in JS with the Squirrel hooks results in file is locked errors (as you are trying to delete files that are in use).

@develar
Copy link
Contributor

develar commented Jul 4, 2016

+1 (I haven't check, really, Doesn't Squirrel.Windows remove app data on uninstall?) But I guess that issue should be opened in the Squirrel.Windows issue tracker.

BTW, electron-builder NSIS uninstaller deletes app data on uninstall.

Code: https://github.com/Squirrel/Squirrel.Windows/blob/master/src/Squirrel/UpdateManager.ApplyReleases.cs#L92 Not yet checked, but it seems, yes, Squirrel doesn't remove app data folder.

@wangxiexe
Copy link

+1 for having this feature as default. So at this moment any idea is there any api I can delete that data folder in uninstall event handler?

@MarshallOfSound
Copy link
Member Author

@wangxiexe

require('rimraf').sync(require('electron').app.getPath('userData'));

Inside the --squirrel-uninstall event

@wangxiexe
Copy link

wangxiexe commented Aug 16, 2016

@MarshallOfSound actually I tried this but what I notice is that if I did not close my app when run uninstall, uninstall does not work at all.

I guess when the app is running, the userdata directory is being used so rimraf failed

I also tried calling app.quit() before that remove statement, it did not help either..

btw, I am running an app based on electron and if I did not call rimraf during unstall like this

    app.quit()
    return true;

it work fine and even if the app is up and running, uninstall will close it firstly and uninstall successfully

@andymartinwork
Copy link

@wangxiexe

The optimal situation for this would be for the app to inform the other running instances of the app to quit. I tried it using the app api but couldn't make it work.

The hacky solution was to put a try catch around the rimraf command.

@ianrtracey
Copy link

+1 on this. Currently using the installer on a project and users were startled to see the userData directory still populated with files. I can take a stab at this if the issue is still open.

@ianrtracey
Copy link

Going to take a stab at this.

@topched
Copy link

topched commented Jun 24, 2017

@ianrtracey Did you ever come up with a solution for this? Currently stuck on the same problem and nothing seems to work.

@ianrtracey
Copy link

Got bogged down. Will take a look at this this weekend @topched .

@karthik-gumpu
Copy link

I am also facing the same issue. Any solution?

@MarshallOfSound
Copy link
Member Author

I provided a solution to this issue a few comments in, see #113 (comment)

@locpv-ibl
Copy link

any updated? I'm facing the same issue too.

@karthik-gumpu
Copy link

I removed preferences file(which contains all logged in user data) from app data like below on squirrel uninstall event.

//Remove local preferences file
rimraf.sync(path.join(app.getPath('userData'),'pref.json'),null,function(error){
if(error){
log.error(err);
}
});

@info-ankit
Copy link

info-ankit commented May 11, 2019

Any Updates?? Still i am facing same issue...

I am using -

require('rimraf').sync(require('electron').app.getPath('userData'));

Inside the --squirrel-uninstall event

@Vashkatsi
Copy link

@wangxiexe

require('rimraf').sync(require('electron').app.getPath('userData'));

Inside the --squirrel-uninstall event

Cant find how to set --squirrel-uninstall`, can you show example, please.

@balamgithub
Copy link

@wangxiexe

require('rimraf').sync(require('electron').app.getPath('userData'));

Inside the --squirrel-uninstall event

Cant find how to set --squirrel-uninstall`, can you show example, please.

Go to "test-app-one" project inside electron-builder git source repo.

@paragdulam
Copy link

paragdulam commented Oct 8, 2020

Lets say the electron windows app is installed on a windows machine which has multiple windows users(Administrator and other user accounts).

    "nsis": {
        "deleteAppDataOnUninstall": true,
        "oneClick": false
    }

I have deleteAppDataOnUninstall to true in package.json.

Issue:
The app data gets deleted from the user who uninstalled the app. e.g. if a non-admin account uninstalls the app from Control Panel, that user's appData gets deleted but NOT OF OTHERS.

When the app is reinstalled, Other windows accounts wont get a fresh newly installed app. The one who uninstalled the app only that user account gets a newly installed app.

How can we delete all the app user data for all accounts when app is uninstalled?
@MarshallOfSound

@SnehalJ1509
Copy link

SnehalJ1509 commented Jan 29, 2021

Lets say the electron windows app is installed on a windows machine which has multiple windows users(Administrator and other user accounts).

    "nsis": {
        "deleteAppDataOnUninstall": true,
        "oneClick": false
    }

I have deleteAppDataOnUninstall to true in package.json.

Issue:
The app data gets deleted from the user who uninstalled the app. e.g. if a non-admin account uninstalls the app from Control Panel, that user's appData gets deleted but NOT OF OTHERS.

When the app is reinstalled, Other windows accounts wont get a fresh newly installed app. The one who uninstalled the app only that user account gets a newly installed app.

How can we delete all the app user data for all accounts when app is uninstalled?
@MarshallOfSound

@paragdulam Thank you for your solution! It works as expected in Windows. Do you or anyone have any idea if anything similar is available for MacOS? I am creating a .dmg and then installing or re-installing the app via it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests