Closed Bug 652850 Opened 13 years ago Closed 13 years ago

SafeInstallOperation can't rollback move/rename operations

Categories

(Toolkit :: Add-ons Manager, defect)

defect
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla6

People

(Reporter: ma1, Assigned: mossop)

References

Details

(Whiteboard: [tests on bug 653835])

Attachments

(1 file)

While investigating code possibly involved with bug 644856, I've found http://mxr.mozilla.org/mozilla-central/source/toolkit/mozapps/extensions/XPIProvider.jsm#201 is probably incorrect:

this._installedFiles.push({ oldFile: null, newFile: newFile });

should be actually

this._installedFiles.push({ oldFile: oldFile, newFile: newFile });

otherwise http://mxr.mozilla.org/mozilla-central/source/toolkit/mozapps/extensions/XPIProvider.jsm#188 is meaningless and the oldFile variable useless.

The effect of the current code is that move/rename operations cannot be rolled back because the original path gets lost.
Attached patch patch rev 1Splinter Review
Well damn, good catch.

Going to have to think of how I can do proper testing here, simulating file move failures isn't easy though
Assignee: nobody → dtownsend
Status: NEW → ASSIGNED
Attachment #528345 - Flags: review?
(In reply to comment #1)
> simulating file
> move failures isn't easy though

Wouldn't moving to a surely non-existent path always fail?
Attachment #528345 - Flags: review? → review?(robert.bugzilla)
(In reply to comment #2)
> (In reply to comment #1)
> > simulating file
> > move failures isn't easy though
> 
> Wouldn't moving to a surely non-existent path always fail?

Yes, but the code always erases the target path and recreates it as it moves the files. If I do something to make the target always unwritable then we'd never get to the SafeInstallOperation code. I think I can create some fake nsIFile instances to simulate failing to move a specific file, but I need to play around with it.
Comment on attachment 528345 [details] [diff] [review]
patch rev 1

Might be able to test this on Windows by using a file stream.

File a followup for tests?
Attachment #528345 - Flags: review?(robert.bugzilla) → review+
This landed yesterday: http://hg.mozilla.org/mozilla-central/rev/e4e42dac5104

Bug for tests: bug 653835
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla6
Verified fixed by check-in (merge) on aurora. I will also connect the corresponding bug for the tests and set the in-testsuite? flag, so we do not forget about it.
Blocks: 653835
Status: RESOLVED → VERIFIED
Flags: in-testsuite?
Flags: in-litmus-
Whiteboard: [tests on bug 653835]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: