diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-11-17 00:28:22 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-11-17 00:28:22 +0000 |
commit | 1305f1225085f8e3ba9febfbc2e9895a91d4a510 (patch) | |
tree | e3d5b129ced12d3dff9d90d0fd0da7f4bb20b4ec /lib/thandy/download.py | |
parent | 3b66334024cc251ff3734df6a2708c5e89d4af06 (diff) |
make log levels configurable. check file hashes correctly.
git-svn-id: file:///home/or/svnrepo/updater/trunk@17301 55e972cd-5a19-0410-ae62-a4d7a52db4cd
Diffstat (limited to 'lib/thandy/download.py')
-rw-r--r-- | lib/thandy/download.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/thandy/download.py b/lib/thandy/download.py index aaa8215..dab9a2c 100644 --- a/lib/thandy/download.py +++ b/lib/thandy/download.py @@ -130,16 +130,18 @@ class DownloadManager: class DownloadJob: """Abstract base class. Represents a thing to be downloaded, and the knowledge of how to download it.""" - def __init__(self, targetPath, tmpPath, wantHash=None, useTor=False): + def __init__(self, targetPath, tmpPath, wantHash=None, repoFile=None, + useTor=False): """Create a new DownloadJob. When it is finally downloaded, store it in targetPath. Store partial results in tmpPath; if there is already a file in tmpPath, assume that it is an incomplete download. If wantHash, reject the file unless the hash is as given. If useTor, use a socks connection.""" - + #DOCDODC repofile self._destPath = targetPath self._tmpPath = tmpPath self._wantHash = wantHash + self._repoFile = repoFile self._useTor = useTor self._success = lambda : None @@ -235,10 +237,12 @@ class DownloadJob: if f_out is not None: f_out.close() - if self._wantHash: + if self._wantHash and not self._repoFile: gotHash = thandy.formats.getFileDigest(self._tmpPath) if gotHash != self._wantHash: raise thandy.DownloadError("File hash was not as expected.") + elif self._repoFile: + self._repoFile.checkFile(self._tmpPath, self._wantHash) thandy.util.ensureParentDir(self._destPath) thandy.util.moveFile(self._tmpPath, self._destPath) @@ -264,10 +268,10 @@ class ThandyDownloadJob(DownloadJob): """Thandy's subtype of DownloadJob: knows about mirrors, weighting, and Thandy's directory structure.""" def __init__(self, relPath, destPath, mirrorList, wantHash=None, - supportedURLTypes=None, useTor=None): + supportedURLTypes=None, useTor=None, repoFile=None): DownloadJob.__init__(self, destPath, None, wantHash=wantHash, - useTor=useTor) + useTor=useTor, repoFile=repoFile) self._mirrorList = mirrorList self._relPath = relPath |