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

Keep specific folders after update #7914

Open
ribeirogab opened this issue Dec 1, 2023 · 3 comments
Open

Keep specific folders after update #7914

ribeirogab opened this issue Dec 1, 2023 · 3 comments
Labels

Comments

@ribeirogab
Copy link

  • Electron-Builder Version: 24.6.4
  • Node Version: 20.10.0
  • Electron Version: 26.2.1
  • Electron Type (current, beta, nightly): current
  • Target: Windows

Related issues:

I would like to understand why all folders and files are excluded on automatic update.

I have a use case where I need to maintain a specific folder that is in the application directory. This folder is downloaded at run time and is of considerable size, making it impossible to download every time the application is opened.

NOTE: I cannot save to AppData or another persistent directory as I give the user the option to choose the installation directory.

Thanks!

@ribeirogab
Copy link
Author

Workaround from #2181 (comment)

Use NIS script to create a customRemoveFiles macro, where when it is an update it will ignore the deletion:

build/installer.nsh:

!macro preInit
${ifNot} ${isUpdated}
	SetRegView 64
	WriteRegExpandStr HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\MyApp"
	WriteRegExpandStr HKCU "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\MyApp"
	SetRegView 32
	WriteRegExpandStr HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\MyApp"
	WriteRegExpandStr HKCU "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\MyApp"
${endIf}
!macroend

!macro customRemoveFiles
${if} ${isUpdated}
  !insertmacro quitSuccess
${else}
  RMDir /r $INSTDIR
${endIf}
!macroend

electron-builder (package.json in my case):

{
  "build": {
    "nsis": {
      "allowToChangeInstallationDirectory": true,
      "createDesktopShortcut": true,
      "oneClick": false,
      "license": "license.txt",
      "include": "build/installer.nsh"
    }
  }
}

DISCLAIMER: I don't know if this could have a negative impact on the application.

@qkrooz
Copy link

qkrooz commented Feb 27, 2024

Hello!

Where do you specify the folder to not be deleted?

Copy link
Contributor

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants