diff options
Diffstat (limited to 'apt/cache.py')
| -rw-r--r-- | apt/cache.py | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/apt/cache.py b/apt/cache.py index 342dbfb5..973ffea5 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -112,24 +112,7 @@ class Cache(object): self._depcache.Upgrade(distUpgrade) self.cachePostChange() - def update(self, fetchProgress=None, opProgress=None): - if(opProgress != None): - self._cache.Update(fetchProgress, opProgress); - else: - self._cache.Update(fetchProgress); - - def _fetchArchives(self, fetcher, pm, fetchProgress): - """ fetch the needed archives """ - - # get lock - lockfile = apt_pkg.Config.FindDir("Dir::Cache::Archives") + "lock" - lock = apt_pkg.GetLock(lockfile) - if lock < 0: - raise IOError, "Failed to lock %s" % lockfile - - # this may as well throw a SystemError exception - if not pm.GetArchives(fetcher, self._list, self._records): - return False + def _runFetcher(self, fetcher): # do the actual fetching res = fetcher.Run() if res == fetcher.ResultFailed: @@ -140,7 +123,8 @@ class Cache(object): transient = False errMsg = "" for item in fetcher.Items: - if item.StatDone and item.Complete: + print item + if item.Status == item.StatDone: continue if item.StatIdle: transient = True @@ -151,10 +135,42 @@ class Cache(object): # we raise a exception if the download failed if failed: raise IOError, errMsg + return res + + def _fetchArchives(self, fetcher, pm, fetchProgress): + """ fetch the needed archives """ + # get lock + lockfile = apt_pkg.Config.FindDir("Dir::Cache::Archives") + "lock" + lock = apt_pkg.GetLock(lockfile) + if lock < 0: + raise IOError, "Failed to lock %s" % lockfile + + # this may as well throw a SystemError exception + if not pm.GetArchives(fetcher, self._list, self._records): + return False + # now run the fetcher, throw exception if something fails to be + # fetched + res = self._runFetcher(fetcher) + # cleanup os.close(lock) return res + + def update(self, fetchProgress=None): + lockfile = apt_pkg.Config.FindDir("Dir::State::Lists") + "lock" + lock = apt_pkg.GetLock(lockfile) + if lock < 0: + raise IOError, "Failed to lock %s" % lockfile + if fetchProgress == None: + fetchProgress = apt.progress.FetchProgress() + fetcher = apt_pkg.GetAcquire(fetchProgress) + # this can throw a exception + self._list.GetIndexes(fetcher) + # now run the fetcher, throw exception if something fails to be + # fetched + res = self._runFetcher(fetcher) + return res def installArchives(self, pm, installProgress): installProgress.startUpdate() |
