From 2ec858bc68bc2d79ec020fe24be2d76b7c5b6792 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 28 Jul 2011 15:16:18 +0200 Subject: * apt-pkg/contrib/fileutl.{cc,h}: - add GetModificationTime() helper * apt-pkg/pkgcachegen.cc: - regenerate the cache if the sources.list changes to ensure that changes in the ordering there will be honored by apt * apt-pkg/sourcelist.{cc,h}: - add pkgSourceList::GetLastModifiedTime() helper --- apt-pkg/sourcelist.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'apt-pkg/sourcelist.cc') diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index 851eefdfe..c96ccfd77 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -341,4 +341,22 @@ bool pkgSourceList::ReadSourceDir(string Dir) } /*}}}*/ +// GetLastModified() /*{{{*/ +// --------------------------------------------------------------------- +/* */ +time_t pkgSourceList::GetLastModifiedTime() +{ + // go over the parts + string Main = _config->FindFile("Dir::Etc::sourcelist"); + string Parts = _config->FindDir("Dir::Etc::sourceparts"); + vector const List = GetListOfFilesInDir(Parts, "list", true); + + // calculate the time + time_t mtime_sources = GetModificationTime(Main); + for (vector::const_iterator I = List.begin(); I != List.end(); I++) + mtime_sources = std::max(mtime_sources, GetModificationTime(*I)); + + return mtime_sources; +} + /*}}}*/ -- cgit v1.2.3 From 5e7b0aa9eb884f663c3a87968057d9f540fe0175 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 1 Aug 2011 10:56:49 +0200 Subject: apt-pkg/sourcelist.cc: GetListOfFilesInDir() fails if the dir does not exists, so test before using that --- apt-pkg/sourcelist.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'apt-pkg/sourcelist.cc') diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index c96ccfd77..aaff16316 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -346,10 +346,14 @@ bool pkgSourceList::ReadSourceDir(string Dir) /* */ time_t pkgSourceList::GetLastModifiedTime() { - // go over the parts + vector List; + string Main = _config->FindFile("Dir::Etc::sourcelist"); string Parts = _config->FindDir("Dir::Etc::sourceparts"); - vector const List = GetListOfFilesInDir(Parts, "list", true); + + // go over the parts + if (DirectoryExists(Parts) == true) + List = GetListOfFilesInDir(Parts, "list", true); // calculate the time time_t mtime_sources = GetModificationTime(Main); -- cgit v1.2.3 From f7f0d6c7560a8f71707e7852a512469147aa9f84 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 11 Aug 2011 20:53:28 +0200 Subject: cppcheck complains about some possible speed improvements which could be done on the mirco-optimazation level, so lets fix them: (performance) Possible inefficient checking for emptiness. (performance) Prefer prefix ++/-- operators for non-primitive types. --- apt-pkg/sourcelist.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'apt-pkg/sourcelist.cc') diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index c96ccfd77..a25358bf2 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -173,7 +173,7 @@ pkgSourceList::pkgSourceList(string File) /* */ pkgSourceList::~pkgSourceList() { - for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++) + for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I) delete *I; } /*}}}*/ @@ -218,7 +218,7 @@ bool pkgSourceList::ReadMainList() /* */ void pkgSourceList::Reset() { - for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++) + for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I) delete *I; SrcList.erase(SrcList.begin(),SrcList.end()); } @@ -296,11 +296,11 @@ bool pkgSourceList::ReadAppend(string File) bool pkgSourceList::FindIndex(pkgCache::PkgFileIterator File, pkgIndexFile *&Found) const { - for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++) + for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I) { vector *Indexes = (*I)->GetIndexFiles(); for (vector::const_iterator J = Indexes->begin(); - J != Indexes->end(); J++) + J != Indexes->end(); ++J) { if ((*J)->FindInCache(*File.Cache()) == File) { @@ -318,7 +318,7 @@ bool pkgSourceList::FindIndex(pkgCache::PkgFileIterator File, /* */ bool pkgSourceList::GetIndexes(pkgAcquire *Owner, bool GetAll) const { - for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++) + for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I) if ((*I)->GetIndexes(Owner,GetAll) == false) return false; return true; @@ -334,7 +334,7 @@ bool pkgSourceList::ReadSourceDir(string Dir) vector const List = GetListOfFilesInDir(Dir, "list", true); // Read the files - for (vector::const_iterator I = List.begin(); I != List.end(); I++) + for (vector::const_iterator I = List.begin(); I != List.end(); ++I) if (ReadAppend(*I) == false) return false; return true; @@ -353,7 +353,7 @@ time_t pkgSourceList::GetLastModifiedTime() // calculate the time time_t mtime_sources = GetModificationTime(Main); - for (vector::const_iterator I = List.begin(); I != List.end(); I++) + for (vector::const_iterator I = List.begin(); I != List.end(); ++I) mtime_sources = std::max(mtime_sources, GetModificationTime(*I)); return mtime_sources; -- cgit v1.2.3