Closed Bug 164190 Opened 22 years ago Closed 22 years ago

nsSafeSaveFile mistreats nsLocalFile, deleting files under one.

Categories

(Core :: Preferences: Backend, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: sfraser_bugs, Assigned: bnesse)

Details

Attachments

(2 files, 1 obsolete file)

nsSafeSaveFile has this pattern (mTarget and mBackup are both nsILocalFiles).
Pseudocode:

  mTarget->Clone(&mBackup);
  mBackup->Remove();  // bye bye
  mBackup->GetParent(); // whoops

This hoses the Mac OS X nsLocalFileImpl, which is a separate issue (bug 164189).
It's easy to fix, and makes more sense this way too:

  mTarget->Clone(&mBackup);
  mBackup->Remove();  // bye bye
  mTarget->GetParent(); // ok
Attachment #96410 - Attachment is obsolete: true
Comment on attachment 96412 [details] [diff] [review]
Better patch: just pass nsnull as the parent

sr=alecf
Attachment #96412 - Flags: superreview+
Comment on attachment 96412 [details] [diff] [review]
Better patch: just pass nsnull as the parent

r=ccarlen
Attachment #96412 - Flags: review+
Checked in sfrasers patch.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Had to back this out. It turned the "brad" and "Btek" linux Tinderboxen orange.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
This patch might cause dataloss.

I did a CVS pull & compile yesterday and now my prefs.js AND prefs.bak files
keep getting deleted - this backed-out patch looks a likely candidate ;-)
This patch caused bug 164345. From that bug:
>nsSafeSaveFile::CreateBackup() calls CopyToNative with a 1st parameter of
>nsnull.  That's "newParent" in io/nsLocalFileUnix.cpp's CopyToNative(), and
>there's no check for a null newParent before using it.

>Win32 (nsLocalFileWin.cpp) ends up checking for/handling a null newParent.

So it seems that Win and Mac handle this case, but Unix does not.
Please go back to the original (simpler) patch which does not have this bug...
Comment on attachment 96410 [details] [diff] [review]
nsSafeSaveFile patch; use mTargetFile to get the parent, not mBackupFile

un-obsoleting;
r=rjesup@wgate.com
Attachment #96410 - Attachment is obsolete: false
Attachment #96410 - Flags: review+
Comment on attachment 96412 [details] [diff] [review]
Better patch: just pass nsnull as the parent

obsoleting nsnull version of the patch.  If you want to go back to using this
version, the bug in file IO will need to be fixed first.
Attachment #96412 - Attachment is obsolete: true
The cause of this problem, bug 165561, is checked in. Passing nsnull as the
parent to copyToNative now works on Unix. I think the original patch could go
back in now.
As per Conrad's comment, landed patch again.
Status: REOPENED → RESOLVED
Closed: 22 years ago22 years ago
Resolution: --- → FIXED
With my cvs build on windows from 5PM today, I'm seeing prefs.js being deleted 
on shutdown.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Me too, on the Phoenix tinderbox.  This is bad.  Does windows LocalFile
implementation not handle this case?
I think the problem is that in the windows implementation of CopyToNative (which
calls CopyMove), we incorrectly decide that a null parent means we should always
rename instead of copy.  Oops.
patch coming up for what I think is the underlying LocalFileWin problem.
Comment on attachment 100078 [details] [diff] [review]
LocalFileWin patch

r/sr=brendan@mozilla.org

/be
Attachment #100078 - Flags: superreview+
Comment on attachment 100078 [details] [diff] [review]
LocalFileWin patch

r=hewitt
Attachment #100078 - Flags: review+
patch checked in, reclosing.
Status: REOPENED → RESOLVED
Closed: 22 years ago22 years ago
Resolution: --- → FIXED
Argh. This broke OS/2. We are a port of nsLocalFileWin.
OS/2 bug 170638: should it be duped to this and this reopened?
OS/2 fix is already in - same as nsLocalFileWin fix.

We should be done here.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: