Electron-builder: Question: remove app data on uninstall by default

Created on 30 Jan 2017  ·  19Comments  ·  Source: electron-userland/electron-builder

  • Version: 12.0.3
  • Target: win


Hi!
How can app data under Roaming/AppName be removed by default without asking users about it? It seems like there is an option "--delete-app-data". But how can I apply it to the uninstaller by default? Using custom uninstall script? Is there another way like additional option in package.json?

duplicate feature nsis

Most helpful comment

@develar it is a request from users :) They want to completely remove all data when uninstall the app (but not during updates, of course). And I agree with them, because there is no reason to store unusable data of uninstalled app.

All 19 comments

Using custom uninstall script

For now, yes.

Is there another way like additional option in package.json?

PR welcome.

Do you use boring or one-click installer?

Related: #885

Got it, thanks for the answer. I use one-click installer.

@clusterberries For what do you need to remove app data on uninstall?

Duplicates #885

@develar it is a request from users :) They want to completely remove all data when uninstall the app (but not during updates, of course). And I agree with them, because there is no reason to store unusable data of uninstalled app.

Ok, If you feel that it is a better default option for your app. But am sure that default value should be false — do not remove app data by default.

I cannot promise that #885 will be fixed this month.

@develar I agree about default value.
Thank you in any case 😊

Hello @clusterberries

Have you managed to create the custom uninstall script to delete that folder? I'm trying to do the same but I have no clue.

Thanks in advance.

Hi @darwinrc
I'm working on it right now. And it seems like this code in build/installer.nsh script solves the issue

!macro customUnInstall
  RMDir /r "$APPDATA\${APP_FILENAME}"
!macroend

@develar I need some help from your side, please. How to remove data only on uninstall and save it during updates? I tried

  ${GetOptions} $R0 "--update" $R1
  ${If} ${Errors}
    RMDir /r "$APPDATA\${APP_FILENAME}"
  ${endif}

But this code removes data during updates. Is it an issue or the code is wrong?
ps: I also tried ${IfNot} ${Silent}, but it does't delete userdata at all.

@clusterberries Please try to call ClearErrors before.

Or... just send us a PR and I will be forced to fix it finally. You don't need to file a complete PR, I will finish it if need.

@clusterberries Will be fixed today.

@develar, I've already tried to add ClearErrors, but it didn't help. How can I send a PR if it doesn't work?
Great, thanks! :)

@clusterberries error in the name — --updated, but not --update :) In any case feature is nearly ready to push.

@clusterberries Попробуйте 13.7.0.

@develar , I checked the new option and it works!
Спасибо огромное :)

@clusterberries I see that you edited your feedback, but anyway I have the answer — new installer calls old uninstaller — in your case, I suppose, some old test (your attempt to fix issue) uninstaller was called and data was removed.

To ensure user safety — installer always pass --updated flag to uninstaller (i.e. currently if you call installer manually, uninstaller will get --updated flag).

Hi @darwinrc
I'm working on it right now. And it seems like this code in build/installer.nsh script solves the issue

!macro customUnInstall
  RMDir /r "$APPDATA\${APP_FILENAME}"
!macroend

how to do it for Linux, I tried adding a custom script in

deb:{
 "fpm":["--after-remove=build/remove.sh"]
}

the problem is that custom script doesn't have access to any environmental variables like $HOME and it is not expanding ~ so there is no way for me to locate the application data. Any help would be appreciated @clusterberries

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mstralka picture mstralka  ·  3Comments

popod picture popod  ·  3Comments

leo picture leo  ·  3Comments

philcockfield picture philcockfield  ·  3Comments

jhg picture jhg  ·  3Comments