Closed Bug 326895 Opened 20 years ago Closed 20 years ago

Extension isn't uninstalled cleanly when its folder is in use ( safeInstallOperation failure )

Categories

(Toolkit :: Add-ons Manager, defect)

x86
Windows XP
defect
Not set
minor

Tracking

()

RESOLVED FIXED
mozilla1.8.1alpha1

People

(Reporter: ancestor.ak, Assigned: mossop)

Details

(Keywords: fixed1.8.0.4, fixed1.8.1)

Attachments

(1 file, 1 obsolete file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20060211 Firefox/1.5 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20060211 Firefox/1.5 When the extension folder is in use, the files get deleted but the folder does not and a phantom extension is left in the EM. Trying to bring up Options of the phantom extension freezes Firefox. The extension disappears after the folder is no longer in use. Same happens with themes. Reproducible: Always Steps to Reproduce: 1. Make the extension folder in use e.g. open it in Total Commander (Windows Explorer won't do). 2. Uninstall the extension and restart Firefox. 3. The files are deleted but the folder remains. There's a phantom extension in the EM. 4. Try to bring up Options of the extension - this freezes Firefox. 5. After the folder is no longer in use, the extension gets cleaned up on the next restart. Maybe we shouldn't uninstall anything until the folder is deletable. Leaving user with a permanent message that the extension will be uninstalled on the next restart which doesn't happen isn't perfect but it's definitely better. Normal users don't mess with folders in profile anyway, so the exposure is very low unless there are other variations of this bug.
This is caused by the code for putting back the files on removal failure not working properly in all situations.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: Extension isn't uninstalled cleanly when its folder is in use. → Extension isn't uninstalled cleanly when its folder is in use ( safeInstallOperation failure )
Assignee: nobody → mossop
Status: NEW → ASSIGNED
Attached patch Fix rollback (obsolete) — Splinter Review
This patch makes three main changes: Firstly rollbackMove is changed to remove files from the movedFiles array as each is rolled back. This is not really necessary for the rest of this patch or for any other situation I can think of, but I think it makes the system a bit cleaner. Secondly moveDirectory previously absorbed any exceptions thrown from moveFile. That meant that if moveFile failed, the uninstallation would continue and try to remove the remaining files from the item location. Thirdly, moveDirectory was basically broken because it did not QI the directoryEntries to a nsIDirectoryEnumerator, then attempted to use it as one, so no files were ever moved away and when any extension removal/upgrade failed, rollback didnt have anything to rollback.
Attachment #214096 - Flags: review?(robert.bugzilla)
Comment on attachment 214096 [details] [diff] [review] Fix rollback Dave, thanks for taking care of this. > function rollbackMove() > { >- for (var i = 0; i < movedFiles.length; ++i) { >- var oldFile = movedFiles[i].oldFile; >- var newFile = movedFiles[i].newFile; >+ while (movedFiles.length > 0) { >+ var movedFile = movedFiles.pop(); >+ var oldFile = movedFile.oldFile; >+ var newFile = movedFile.newFile; > try { > newFile.moveTo(oldFile.parent, newFile.leafName); > } > catch (e) { >+ movedFiles.push(movedFile); Since this throws at this point what is the value of adding back the file it failed to move? I'm not entirely sure there isn't an edgecase where the last file in the array being rolled back won't fail and with the old way going from first to last it would at least put back all the files before failing entirely - that is if it had been working in the first place. :/ Since this change isn't needed I feel safer leaving it the way it was. >+ while (true) { >+ var entry = entries.nextFile; >+ if (!entry) >+ break; >+ if (entry.isDirectory()) >+ moveDirectory(sourceDir, targetDir, entry); >+ else { >+ if (entry instanceof nsILocalFile) { nit: this should be changed to an else if With those two items fixed r=me and thanks again!
Attachment #214096 - Flags: review?(robert.bugzilla) → review+
(In reply to comment #3) > Since this change isn't needed I feel safer leaving it the way it was. That's fair enough. > With those two items fixed r=me and thanks again! Cheers :)
Attached patch Final patchSplinter Review
Addressed comments, carried over review.
Attachment #214096 - Attachment is obsolete: true
Attachment #214290 - Flags: review+
Checked in on trunk
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 2 alpha1
Comment on attachment 214290 [details] [diff] [review] Final patch a=ben@mozilla.org for the 1.8.1 branch
Attachment #214290 - Flags: approval-branch-1.8.1+
Fixed on MOZILLA_1_8_BRANCH
Keywords: fixed1.8.1
Comment on attachment 214290 [details] [diff] [review] Final patch Please check in promptly on the 1.8.0 branch. Thanks!
Attachment #214290 - Flags: approval1.8.0.3? → approval1.8.0.3+
Checked in to MOZILLA_1_8_0_BRANCH Checking in mozilla/toolkit/mozapps/extensions/src/nsExtensionManager.js.in; /cvsroot/mozilla/toolkit/mozapps/extensions/src/nsExtensionManager.js.in,v <-- nsExtensionManager.js.in new revision: 1.144.2.16.2.6; previous revision: 1.144.2.16.2.5
Keywords: fixed1.8.0.3
Product: Firefox → Toolkit
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: