diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2005-11-17 13:03:56 +0000 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2005-11-17 13:03:56 +0000 |
| commit | 3c3dd501e3105b7623e07b71f1a59b671dafcafd (patch) | |
| tree | 9478e40e3acfaf0b9451e2f7f876f2bfbba752bb | |
| parent | 25b0cfc0fe92da8a0114bd15aec16e47318b6f48 (diff) | |
| download | python-apt-3c3dd501e3105b7623e07b71f1a59b671dafcafd.tar.gz | |
* fail if a download fails
| -rw-r--r-- | apt/cache.py | 2 | ||||
| -rw-r--r-- | debian/changelog | 6 | ||||
| -rw-r--r-- | python/depcache.cc | 20 |
3 files changed, 25 insertions, 3 deletions
diff --git a/apt/cache.py b/apt/cache.py index 973291c0..1fb128a3 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -117,7 +117,7 @@ class Cache(object): def commit(self, fprogress, iprogress): """ Apply the marked changes to the cache """ - self._depcache.Commit(fprogress, iprogress) + return self._depcache.Commit(fprogress, iprogress) # cache changes def cachePostChange(self): diff --git a/debian/changelog b/debian/changelog index de986f32..51041924 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +python-apt (0.6.14.1) unstable; urgency=low + + * fix a invalid return from cache.commit(), fail if a download failed + + -- Michael Vogt <michael.vogt@ubuntu.com> Thu, 17 Nov 2005 13:00:14 +0100 + python-apt (0.6.14) unstable; urgency=low * doc/examples/build-deps.py: diff --git a/python/depcache.cc b/python/depcache.cc index df56da61..6d5e9fcd 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -116,17 +116,25 @@ static PyObject *PkgDepCacheCommit(PyObject *Self,PyObject *Args) bool Failed = false; for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++) { + + //std::cout << "looking at: " << (*I)->DestFile + // << " status: " << (*I)->Status << std::endl; + if ((*I)->Status == pkgAcquire::Item::StatDone && (*I)->Complete == true) continue; if ((*I)->Status == pkgAcquire::Item::StatIdle) { + //std::cout << "transient failure" << std::endl; + Transient = true; - // Failed = true; + //Failed = true; continue; } + //std::cout << "something is wrong!" << std::endl; + _error->Warning(_("Failed to fetch %s %s\n"),(*I)->DescURI().c_str(), (*I)->ErrorText.c_str()); Failed = true; @@ -135,6 +143,7 @@ static PyObject *PkgDepCacheCommit(PyObject *Self,PyObject *Args) if (Transient == true && Failed == true) { _error->Error(_("--fix-missing and media swapping is not currently supported")); + Py_INCREF(Py_None); return HandleErrors(Py_None); } @@ -143,13 +152,18 @@ static PyObject *PkgDepCacheCommit(PyObject *Self,PyObject *Args) { //std::cerr << "Unable to correct missing packages." << std::endl; _error->Error("Aborting install."); + Py_INCREF(Py_None); return HandleErrors(Py_None); } + // fail if something else went wrong + //FIXME: make this more flexible, e.g. with a failedDl handler + if(Failed) + return Py_BuildValue("b", false); _system->UnLock(); pkgPackageManager::OrderResult Res = iprogress.Run(PM); - std::cout << "iprogress.Run() returned: " << (int)Res << std::endl; + //std::cout << "iprogress.Run() returned: " << (int)Res << std::endl; //FIXME: return usefull values here if (Res == pkgPackageManager::Failed || _error->PendingError() == true) { @@ -159,6 +173,8 @@ static PyObject *PkgDepCacheCommit(PyObject *Self,PyObject *Args) return Py_BuildValue("b", true); } + //std::cout << "looping again, install unfinished" << std::endl; + // Reload the fetcher object and loop again for media swapping Fetcher.Shutdown(); if (PM->GetArchives(&Fetcher,&List,&Recs) == false) { |
