]> git.saurik.com Git - apt.git/blobdiff - cmdline/apt-get.cc
fix apt-get download truncation (closes: #736962)
[apt.git] / cmdline / apt-get.cc
index da7d28a1e9ba8044b1760ae32701b69d43ff7148..6bff6e7de5963d6097e976c2250f2a68b08aefb1 100644 (file)
@@ -678,14 +678,17 @@ bool DoDownload(CommandLine &CmdL)
 
    // copy files in local sources to the current directory
    for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); ++I)
 
    // copy files in local sources to the current directory
    for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); ++I)
-      if ((*I)->Local == true && (*I)->Status == pkgAcquire::Item::StatDone)
+   {
+      std::string const filename = cwd + flNotDir((*I)->DestFile);
+      if ((*I)->Local == true &&
+          filename != (*I)->DestFile &&
+          (*I)->Status == pkgAcquire::Item::StatDone)
       {
       {
-        std::string const filename = cwd + flNotDir((*I)->DestFile);
         std::ifstream src((*I)->DestFile.c_str(), std::ios::binary);
         std::ofstream dst(filename.c_str(), std::ios::binary);
         dst << src.rdbuf();
       }
         std::ifstream src((*I)->DestFile.c_str(), std::ios::binary);
         std::ofstream dst(filename.c_str(), std::ios::binary);
         dst << src.rdbuf();
       }
-
+   }
    return Failed == false;
 }
                                                                        /*}}}*/
    return Failed == false;
 }
                                                                        /*}}}*/