Bug 368317 - temp files remain if MoveToNative fails in nsSafeFileOutputStream::Finish(). patch by Ryan Jones (sciguyryan@gmail.com), r=mvl, sr=biesi

This commit is contained in:
dwitte@stanford.edu 2007-05-20 11:12:26 -07:00
parent 98e31d90cd
commit 7ec8f6a8da

View File

@ -552,12 +552,16 @@ nsSafeFileOutputStream::Finish()
if (NS_FAILED(mTargetFile->Equals(mTempFile, &equal)) || !equal)
NS_ERROR("mTempFile not equal to mTargetFile");
#endif
} else {
nsCAutoString targetFilename;
rv = mTargetFile->GetNativeLeafName(targetFilename);
if (NS_SUCCEEDED(rv))
rv = mTempFile->MoveToNative(nsnull, targetFilename); // This will replace target
}
else {
nsCAutoString targetFilename;
rv = mTargetFile->GetNativeLeafName(targetFilename);
if (NS_SUCCEEDED(rv)) {
// This will replace target.
rv = mTempFile->MoveToNative(nsnull, targetFilename);
if (NS_FAILED(rv))
mTempFile->Remove(PR_FALSE);
}
}
}
else {