From 0d1e224350cda0ddd305baa7da2d7acc01001ebb Mon Sep 17 00:00:00 2001 From: "blakeross%telocity.com" Date: Sun, 10 Nov 2002 04:59:09 +0000 Subject: [PATCH] Move where we record the download start time. git-svn-id: svn://10.0.0.236/trunk@133528 18797224-902f-48f8-a5cc-f745e15eee43 --- .../downloads/src/nsDownloadManager.cpp | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/mozilla/browser/components/downloads/src/nsDownloadManager.cpp b/mozilla/browser/components/downloads/src/nsDownloadManager.cpp index a0bf63dc2b3..368239fcf4c 100644 --- a/mozilla/browser/components/downloads/src/nsDownloadManager.cpp +++ b/mozilla/browser/components/downloads/src/nsDownloadManager.cpp @@ -186,8 +186,25 @@ nsresult nsDownloadManager::DownloadStarted(const PRUnichar* aPath) { nsStringKey key(aPath); - if (mCurrDownloads.Exists(&key)) + if (mCurrDownloads.Exists(&key)) { + + // Assert the date and time that the download ended. + nsCOMPtr dateLiteral; + if (NS_SUCCEEDED(gRDFService->GetDateLiteral(PR_Now(), getter_AddRefs(dateLiteral)))) { + nsCOMPtr res; + nsCOMPtr node; + + gRDFService->GetUnicodeResource(aPath, getter_AddRefs(res)); + + mDataSource->GetTarget(res, gNC_DateStarted, PR_TRUE, getter_AddRefs(node)); + if (node) + mDataSource->Change(res, gNC_DateStarted, node, dateLiteral); + else + mDataSource->Assert(res, gNC_DateStarted, dateLiteral, PR_TRUE); + } + AssertProgressInfoFor(aPath); + } return NS_OK; } @@ -477,21 +494,7 @@ nsDownloadManager::AddDownload(nsIURI* aSource, downloads->RemoveElementAt(itemIndex, PR_TRUE, getter_AddRefs(node)); return rv; } - - nsCOMPtr dateLiteral; - rv = gRDFService->GetDateLiteral(PR_Now(), getter_AddRefs(dateLiteral)); - if (NS_FAILED(rv)) return rv; - mDataSource->GetTarget(downloadRes, gNC_DateStarted, PR_TRUE, getter_AddRefs(node)); - if (node) - rv = mDataSource->Change(downloadRes, gNC_DateStarted, node, dateLiteral); - else - rv = mDataSource->Assert(downloadRes, gNC_DateStarted, dateLiteral, PR_TRUE); - if (NS_FAILED(rv)) { - downloads->IndexOf(downloadRes, &itemIndex); - downloads->RemoveElementAt(itemIndex, PR_TRUE, getter_AddRefs(node)); - return rv; - } - + // Now flush all this to disk nsCOMPtr remote(do_QueryInterface(mDataSource)); rv = remote->Flush();