[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [thandy/master] Actually enforce file lengths when downloading.



Most of the code was already written for this, but we didn't actually pass
the length fields we'd parsed to the downloading logic.
---
 lib/thandy/ClientCLI.py |    3 +++
 lib/thandy/download.py  |    7 +++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/thandy/ClientCLI.py b/lib/thandy/ClientCLI.py
index 1994049..e5b23e5 100644
--- a/lib/thandy/ClientCLI.py
+++ b/lib/thandy/ClientCLI.py
@@ -108,9 +108,11 @@ def update(args):
     # until all downloading files are finished.
     while True:
         hashes = {}
+        lengths = {}
         installable = {}
         logging.info("Checking for files to update.")
         files = repo.getFilesToUpdate(trackingBundles=args, hashDict=hashes,
+                                      lengthDict=lengths,
                                       usePackageSystem=use_packagesys,
                                       installableDict=installable)
 
@@ -186,6 +188,7 @@ def update(args):
                 f, repo.getFilename(f),
                 mirrorlist,
                 wantHash=hashes.get(f),
+                wantLength=lengths.get(f),
                 repoFile=repo.getRequestedFile(f),
                 useTor=(socksPort!=None))
 
diff --git a/lib/thandy/download.py b/lib/thandy/download.py
index f715a23..d5f1629 100644
--- a/lib/thandy/download.py
+++ b/lib/thandy/download.py
@@ -542,9 +542,11 @@ class SimpleDownloadJob(DownloadJob):
     """Testing subtype of DownloadJob: just downloads a URL and writes it to
        disk."""
     def __init__(self, targetPath, url,
-                 wantHash=None, supportedURLTypes=None, useTor=False):
+                 wantHash=None, supportedURLTypes=None, useTor=False,
+                 wantLength=None):
         DownloadJob.__init__(self, targetPath, targetPath+".tmp",
                                  wantHash=wantHash,
+                                 wantLength=length,
                                  useTor=useTor)
         self._url = url
 
@@ -579,9 +581,10 @@ class ThandyDownloadJob(DownloadJob):
        and Thandy's directory structure."""
     def __init__(self, relPath, destPath, mirrorList, wantHash=None,
                  supportedURLTypes=None, useTor=None, repoFile=None,
-                 downloadStatusLog=None):
+                 downloadStatusLog=None, wantLength=None):
 
         DownloadJob.__init__(self, destPath, None, wantHash=wantHash,
+                             wantLength=wantLength,
                              useTor=useTor, repoFile=repoFile)
         self._mirrorList = mirrorList
         self._relPath = relPath
-- 
1.5.6.5