From 8d2bb87fb00e687772bf33e6494f06752ff19483 Mon Sep 17 00:00:00 2001 From: "blakeross%telocity.com" Date: Wed, 19 Jun 2002 19:53:58 +0000 Subject: [PATCH] 142824 - downloads.rdf keeps on growing. patch by jrgm@netscape.com. r=blake sr=ben git-svn-id: svn://10.0.0.236/trunk@123599 18797224-902f-48f8-a5cc-f745e15eee43 --- .../src/nsDownloadManager.cpp | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/mozilla/xpfe/components/download-manager/src/nsDownloadManager.cpp b/mozilla/xpfe/components/download-manager/src/nsDownloadManager.cpp index a97d1c2fd49..c29b544bdbe 100644 --- a/mozilla/xpfe/components/download-manager/src/nsDownloadManager.cpp +++ b/mozilla/xpfe/components/download-manager/src/nsDownloadManager.cpp @@ -623,6 +623,49 @@ nsDownloadManager::RemoveDownload(const char* aPath) nsCOMPtr res; gRDFService->GetResource(aPath, getter_AddRefs(res)); + // remove all the arcs for this resource, and then remove it from the Seq + nsCOMPtr arcs; + rv = mDataSource->ArcLabelsOut(res, getter_AddRefs(arcs)); + if (NS_FAILED(rv)) return rv; + + PRBool moreArcs; + rv = arcs->HasMoreElements(&moreArcs); + if (NS_FAILED(rv)) return rv; + + while (moreArcs) { + nsCOMPtr supports; + rv = arcs->GetNext(getter_AddRefs(supports)); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr arc(do_QueryInterface(supports, &rv)); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr targets; + rv = mDataSource->GetTargets(res, arc, PR_TRUE, getter_AddRefs(targets)); + if (NS_FAILED(rv)) return rv; + + PRBool moreTargets; + rv = targets->HasMoreElements(&moreTargets); + if (NS_FAILED(rv)) return rv; + + while (moreTargets) { + rv = targets->GetNext(getter_AddRefs(supports)); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr target(do_QueryInterface(supports, &rv)); + if (NS_FAILED(rv)) return rv; + + // and now drop this assertion from the graph + rv = mDataSource->Unassert(res, arc, target); + if (NS_FAILED(rv)) return rv; + + rv = targets->HasMoreElements(&moreTargets); + if (NS_FAILED(rv)) return rv; + } + rv = arcs->HasMoreElements(&moreArcs); + if (NS_FAILED(rv)) return rv; + } + PRInt32 itemIndex; downloads->IndexOf(res, &itemIndex); if (itemIndex <= 0)