From 7760b4a0ee334ff04a60086d06548d6bda6d55d9 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 4 Jan 2008 21:31:32 +0100 Subject: * use the new CacheFile::ListUpdate() code * add example in doc/examples/update.py --- python/cache.cc | 49 ++++++++----------------------------------------- 1 file changed, 8 insertions(+), 41 deletions(-) (limited to 'python/cache.cc') diff --git a/python/cache.cc b/python/cache.cc index aa4d9ffc..2bbeb14a 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -24,6 +24,8 @@ #include #include "progress.h" +class pkgSourceList; + /*}}}*/ struct PkgListStruct { @@ -76,53 +78,18 @@ static PyObject *PkgCacheUpdate(PyObject *Self,PyObject *Args) PyObject *CacheFilePy = GetOwner(Self); pkgCacheFile *Cache = GetCpp(CacheFilePy); - PyObject *pyOpProgressInst = 0; PyObject *pyFetchProgressInst = 0; - if (PyArg_ParseTuple(Args, "O|O", &pyFetchProgressInst,&pyOpProgressInst) == 0) + PyObject *pySourcesList = 0; + if (PyArg_ParseTuple(Args, "OO", &pyFetchProgressInst,&pySourcesList) == 0) return 0; - FileFd Lock; - if (_config->FindB("Debug::NoLocking", false) == false) { - Lock.Fd(GetLock(_config->FindDir("Dir::State::Lists") + "lock")); - if (_error->PendingError() == true) - return HandleErrors(); - } - - pkgSourceList List; - if(!List.ReadMainList()) { - Py_INCREF(Py_None); - return HandleErrors(Py_None); - } - PyFetchProgress progress; progress.setCallbackInst(pyFetchProgressInst); + pkgSourceList *source = GetCpp(pySourcesList); + bool res = Cache->ListUpdate(progress, *source); - pkgAcquire Fetcher(&progress); - if (!List.GetIndexes(&Fetcher)) - return HandleErrors(); - if (Fetcher.Run() == pkgAcquire::Failed) { - Py_INCREF(Py_None); - return HandleErrors(Py_None); - } - -#if 0 // reopening the cache is the job of the python code now - // doing it here is wrong and broken - if(pyOpProgressInst != 0) { - PyOpProgress progress; - progress.setCallbackInst(pyOpProgressInst); - if (Cache->Open(progress,false) == false) - return HandleErrors(); - } else { - OpTextProgress Prog; - if (Cache->Open(Prog,false) == false) { - Py_INCREF(Py_None); - return HandleErrors(Py_None); - } - } -#endif - - Py_INCREF(Py_None); - return HandleErrors(Py_None); + PyObject *PyRes = Py_BuildValue("b", res); + return HandleErrors(PyRes); } static PyObject *PkgCacheClose(PyObject *Self,PyObject *Args) -- cgit v1.2.3