Currently, if a problem occurs during native app installation, no cleanup is done on the files that have already been installed/placed on the user's machine. Steps to reproduce: 1. Install the released version of the addon-sdk (this is to ensure that installation fails - known bug) - https://addons.mozilla.org/en-US/developers/builder 2. Install the oauthorizer package into the packages folder of the addon-sdk folder - https://github.com/mozilla/oauthorizer 3. Clone the openwebapps project - https://github.com/mozilla/github 4. Checkout the feature/native-app branch 5. Cd into addons-sdk folder and type 'bin\activate' 6. Cd into openwebapps\addons\jetpack 7. Type cfx --binary=<Path to firefox nightly exe> run - Known bug that can't use release version of FF 8. Go to apps.mozillalabs.com/appdir 9. Try to install an app Actual Results: An error is thrown immediately and the installation fails. A folder with the app name remains in %LOCALAPPDATA% (which will be changed to %APPDATA% soon). Expected Result: An error is shown to the user warning him/her of the failure of the installation and files associated with the app that was unsuccessfully installed are cleaned up. Error: info: APPS | NativeShell | Aborted: createExecutable - Failure copying files ([Exception... "Component returned failurecode: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [nsIChannel.asyncOpen]" nsresult: "0x80520012 (NS_ERROR_FILE_NOT_FOUND)" location: "JS frame :: resource://gre/modules/NetUtil.jsm :: NetUtil_asyncOpen ::line 199" data: no])
This should be fixed in feature/native-app as of this commit: https://github.com/mozilla/openwebapps/commit/045086aa2c883f44d2d394e5185a3412994f4e68 Please reopen if a failed install leaves anything around (directories, files, registry keys, shortcuts)
After a failed installation as per Bug 701610, the folder with the apps name remains in %APPDATA% and within it remains the app icon. Tested with http://people.mozilla.com/~dclarke/openwebapps/Extension/older/openwebapps-5f90c92fd4-11_23_2011.xpi
This seems like a race condition: Before the icon is successfully written, the installation process aborts and attempts to clean up the destination directory.
Created attachment 578097 [details] [diff] [review] Patch v1 (dummy file, see pull request for actual patch) - Fix race conditions leading to partial installations on errors https://github.com/mozilla/openwebapps/pull/140 The race condition mentioned above was definitely a problem, but there was another that took me a while to track down. In the removeInstallation() function, which is called on installation failure to remove the partial installation, we use nsIProcess.run() to run the uninstaller. When that is complete (we run synchronously), we remove the installation dir using nsIFile. The part that should have been synchronous (nsIProcess.run) wasn't actually as synchronous as I initially thought. This is because NSIS uninstallers copy themselves to a temp dir, launch the copy, and terminate the original process (they do this so that the uninstaller itself can be removed by the uninstaller). The result I was seeing is that the installation dir would be correctly removed, but desktop shortcuts and registry keys would stick around.
I did a review on the pull, looks fine, found other issues for Tim to look at.
Other issues for nativeshell.js that I previously mentioned are moved to bug 704574
Merged to develop. This should no longer be an issue in extensions built from the latest develop branch. Please reopen if a failed install leaves anything around (directories, files, registry keys, shortcuts)
Tested on Windows 7, Vista and XP using FF9b4 and openwebapps-2bfe2fa373-12_08_2011.xpi from http://people.mozilla.com/~dclarke/openwebapps/Extension/. After a failed install, a successful uninstall happens that removes the desktop icon and the files within %APPDATA%\<App folder> as expected with a regular uninstall. To test this, I followed Tim's suggestion of changing the permissions of one of the files to read-only and then tried to re-install the app. I also checked this earlier when native install was suddenly broken on Windows and I noticed that a proper cleanup was happening then.
Comment on attachment 578097 [details] [diff] [review] Patch v1 (dummy file, see pull request for actual patch) - Fix race conditions leading to partial installations on errors Canceling review, this was already merged to develop.