X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/53ba4e2c2dd29758be0a911489ca5c23e5107513..2af2eb53e867bfcc0422aaf3c93c79eb2c93e9cc:/ftparchive/cachedb.cc?ds=sidebyside diff --git a/ftparchive/cachedb.cc b/ftparchive/cachedb.cc index f63aa88ab..e56deae1e 100644 --- a/ftparchive/cachedb.cc +++ b/ftparchive/cachedb.cc @@ -97,13 +97,8 @@ bool CacheDB::ReadyDB(std::string const &DB) /* */ bool CacheDB::OpenFile() { - // its open already - if(Fd && Fd->Name() == this->FileName) - return true; - - // a different file is open, close it first - if(Fd && Fd->Name() != this->FileName) - CloseFile(); + // always close existing file first + CloseFile(); // open a new file Fd = new FileFd(FileName,FileFd::ReadOnly); @@ -128,13 +123,8 @@ void CacheDB::CloseFile() // CacheDB::OpenDebFile - Open a debfile /*{{{*/ bool CacheDB::OpenDebFile() { - // debfile is already open - if(DebFile && &DebFile->GetFile() == Fd) - return true; - - // a different debfile is open, close it first - if(DebFile && &DebFile->GetFile() != Fd) - CloseDebFile(); + // always close existing file first + CloseDebFile(); // first open the fd, then pass it to the debDebFile if(OpenFile() == false) @@ -199,7 +189,7 @@ bool CacheDB::GetCurStat() in the database */ /* Get the flags (and mtime) */ - InitQuery("st"); + InitQueryStats(); // Ensure alignment of the returned structure Data.data = &CurStat; Data.ulen = sizeof(CurStat); @@ -262,7 +252,7 @@ bool CacheDB::LoadSource() if ((CurStat.Flags & FlSource) == FlSource) { // Lookup the control information - InitQuery("cs"); + InitQuerySource(); if (Get() == true && Dsc.TakeDsc(Data.data, Data.size) == true) { return true; @@ -280,7 +270,7 @@ bool CacheDB::LoadSource() return _error->Error(_("Failed to read .dsc")); // Write back the control information - InitQuery("cs"); + InitQuerySource(); if (Put(Dsc.Data, Dsc.Length) == true) CurStat.Flags |= FlSource; @@ -296,7 +286,7 @@ bool CacheDB::LoadControl() if ((CurStat.Flags & FlControl) == FlControl) { // Lookup the control information - InitQuery("cl"); + InitQueryControl(); if (Get() == true && Control.TakeControl(Data.data,Data.size) == true) return true; CurStat.Flags &= ~FlControl; @@ -313,7 +303,7 @@ bool CacheDB::LoadControl() return _error->Error(_("Archive has no control record")); // Write back the control information - InitQuery("cl"); + InitQueryControl(); if (Put(Control.Control,Control.Length) == true) CurStat.Flags |= FlControl; return true; @@ -331,7 +321,7 @@ bool CacheDB::LoadContents(bool const &GenOnly) return true; // Lookup the contents information - InitQuery("cn"); + InitQueryContent(); if (Get() == true) { if (Contents.TakeContents(Data.data,Data.size) == true) @@ -349,7 +339,7 @@ bool CacheDB::LoadContents(bool const &GenOnly) return false; // Write back the control information - InitQuery("cn"); + InitQueryContent(); if (Put(Contents.Data,Contents.CurSize) == true) CurStat.Flags |= FlContents; return true; @@ -515,11 +505,11 @@ bool CacheDB::Finish() if (CurStat.Flags == OldStat.Flags && CurStat.mtime == OldStat.mtime) return true; - + // Write the stat information CurStat.Flags = htonl(CurStat.Flags); CurStat.FileSize = htonl(CurStat.FileSize); - InitQuery("st"); + InitQueryStats(); Put(&CurStat,sizeof(CurStat)); CurStat.Flags = ntohl(CurStat.Flags); CurStat.FileSize = ntohl(CurStat.FileSize);