* Removed the more leftover #pragma interface/implementation
[ntk/apt.git] / apt-pkg / acquire.cc
index ed78ec9..cbd6705 100644 (file)
@@ -190,9 +190,9 @@ void pkgAcquire::Enqueue(ItemDesc &Item)
    Item.Owner->Status = Item::StatIdle;
    
    // Queue it into the named queue
-   I->Enqueue(Item);
-   ToFetch++;
-         
+   if(I->Enqueue(Item)) 
+      ToFetch++;
+            
    // Some trace stuff
    if (Debug == true)
    {
@@ -546,11 +546,17 @@ pkgAcquire::Queue::~Queue()
 // Queue::Enqueue - Queue an item to the queue                         /*{{{*/
 // ---------------------------------------------------------------------
 /* */
-void pkgAcquire::Queue::Enqueue(ItemDesc &Item)
+bool pkgAcquire::Queue::Enqueue(ItemDesc &Item)
 {
    QItem **I = &Items;
-   for (; *I != 0; I = &(*I)->Next);
-   
+   // move to the end of the queue and check for duplicates here
+   for (; *I != 0; I = &(*I)->Next)
+      if (Item.URI == (*I)->URI) 
+      {
+        Item.Owner->Status = Item::StatDone;
+        return false;
+      }
+
    // Create a new item
    QItem *Itm = new QItem;
    *Itm = Item;
@@ -560,6 +566,7 @@ void pkgAcquire::Queue::Enqueue(ItemDesc &Item)
    Item.Owner->QueueCounter++;   
    if (Items->Next == 0)
       Cycle();
+   return true;
 }
                                                                        /*}}}*/
 // Queue::Dequeue - Remove an item from the queue                      /*{{{*/