Closed Bug 368317 Opened 18 years ago Closed 17 years ago

temp files remain if MoveToNative fails in nsSafeFileOutputStream::Finish()

Categories

(Core :: Networking: File, defect)

defect
Not set
major

Tracking

()

RESOLVED FIXED
mozilla1.9alpha5

People

(Reporter: Brade, Assigned: sciguyryan)

References

Details

(Keywords: fixed1.8.1.5)

Attachments

(1 file, 1 obsolete file)

When writing some extension code that uses nsSafeFileOutputStream, I noticed that temp files were not always removed.  I tracked the problem down to the fact that inside nsSafeFileOutputStream::Finish(), mTempFile is not removed when MoveToNative() fails.

Is this behavior intentional?  It seems to me that a failure in the final move should be treated the same as other errors such as failure while writing to the temp file.

I am happy to create a patch if this is indeed a bug.
Possibly related: In one of my main Firefox profiles, I see many files named bookmarks-nn.html.  I'm not sure if this bug is causing that.
For reference, the original work and discussion is in bug 246675.
I'm not planning on working on this: -> default assignee.
Assignee: mvl → nobody
mvl: Is this behaviour actually intended? If not can we actually just remove the backup files without the risk of data loss or could there be another solution too this problem?
I guess one could argue that removing the temp file means there is data that's getting lost.
But because the temp file won't be read anyway, I think that it's OK to remove the temp file.
Attached patch Patch v1 (obsolete) — Splinter Review
Patch v1

Sounds good MVL, patch to make it so.
Assignee: nobody → sciguyryan
Status: NEW → ASSIGNED
Attachment #264390 - Flags: superreview?(cbiesinger)
Attachment #264390 - Flags: review?(cbiesinger)
Attachment #264390 - Flags: superreview?(cbiesinger)
Attachment #264390 - Flags: superreview+
Attachment #264390 - Flags: review?(mvl)
Attachment #264390 - Flags: review?(cbiesinger)
Comment on attachment 264390 [details] [diff] [review]
Patch v1

>Index: netwerk/base/src/nsFileStreams.cpp
>+        else {
>           nsCAutoString targetFilename;
>           rv = mTargetFile->GetNativeLeafName(targetFilename);

I know you are not changing those two lines, but please do fix the indeting to 4 spaces. That's the file's style.

r=mvl
Attachment #264390 - Flags: review?(mvl) → review+
Attached patch For checkinSplinter Review
For checkin. (updated to comments)
Attachment #264390 - Attachment is obsolete: true
Whiteboard: [checkin needed]
do you want this just on trunk? (bug was filed for 1.8 branch)
(In reply to comment #9)
> do you want this just on trunk? (bug was filed for 1.8 branch)
> 

Yea, the "version" should have been set to trunk (and I thought I did that actually).
Version: 1.8 Branch → Trunk
ok, checked in to trunk.
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Whiteboard: [checkin needed]
Flags: in-testsuite-
Er.  It has occurred to me that it *is* actually possible to make MoveToNative reliably fail (permissions would be easiest on Unix-ish platforms, at the least), but I'd been thinking that it wasn't when I set this to -.  Resetting to ? since making it fail reliably is *not* difficult, and thanks to biesi for making me think again about this...
Flags: in-testsuite- → in-testsuite?
Could we please get this patch for the branch as well? This would fix 351551 which can lead to notable performance issues.
Flags: blocking1.8.1.5?
A branch patch would be nice to have, not sure this is a "blocker" though. If you come up with a branch version please request branch approval for it.
Flags: blocking1.8.1.5? → wanted1.8.1.x+
Blocks: 351551
Comment on attachment 265425 [details] [diff] [review]
For checkin

So, this patch even still applies cleanly to the 1.8.1 branch. Nice.
Attachment #265425 - Flags: approval1.8.1.5?
Comment on attachment 265425 [details] [diff] [review]
For checkin

approved for 1.8.1.5, a=dveditz for release-drivers
Attachment #265425 - Flags: approval1.8.1.5? → approval1.8.1.5+
Whiteboard: [checkin needed (1.8 branch)]
Target Milestone: --- → mozilla1.9alpha5
netwerk/base/src/nsFileStreams.cpp 1.72.8.1
Keywords: fixed1.8.1.5
Whiteboard: [checkin needed (1.8 branch)]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: