Path to make FastLoad file removal work on non-Unix systems (must close any streams on it first; 68045, r/sr=jrgm/shaver, a=asa).

git-svn-id: svn://10.0.0.236/trunk@101821 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
brendan%mozilla.org
2001-08-27 05:41:53 +00:00
parent fc4f3e761f
commit 61cb4c1923

View File

@@ -4605,6 +4605,13 @@ nsXULDocument::StartFastLoad()
if (NS_SUCCEEDED(rv)) {
fastLoadService->SetInputStream(objectInput);
} else {
// NB: we must close before attempting to remove, for non-Unix OSes
// that can't do open-unlink.
if (objectInput)
objectInput->Close();
else
input->Close();
#ifdef DEBUG
file->MoveTo(nsnull, "Invalid.mfasl");
#else
@@ -4721,17 +4728,26 @@ nsXULDocument::AbortFastLoads()
NS_BREAK();
#endif
if (gFastLoadFile) {
#ifdef DEBUG
gFastLoadFile->MoveTo(nsnull, "Aborted.mfasl");
#else
gFastLoadFile->Remove(PR_FALSE);
#endif
}
// Save a strong ref to the FastLoad file, so we can remove it after we
// close open streams to it.
nsCOMPtr<nsIFile> file = gFastLoadFile;
// End all pseudo-concurrent XUL document FastLoads, which will close any
// i/o streams open on the FastLoad file.
while (gFastLoadList)
gFastLoadList->EndFastLoad();
// Now rename or remove the file.
if (file) {
#ifdef DEBUG
file->MoveTo(nsnull, "Aborted.mfasl");
#else
file->Remove(PR_FALSE);
#endif
}
// Flush the XUL cache for good measure, in case we cached a bogus/downrev
// script, somehow.
if (gXULCache)
gXULCache->Flush();
return NS_OK;