mirror of
https://github.com/ukui/apt.git
synced 2026-03-09 09:35:45 -07:00
correct some style/performance/warnings from cppcheck
The most "visible" change is from utime to utimensat/futimens as the first one isn't part of POSIX anymore. Reported-By: cppcheck Git-Dch: Ignore
This commit is contained in:
+9
-11
@@ -20,7 +20,6 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <utime.h>
|
||||
#include <unistd.h>
|
||||
#include <apti18n.h>
|
||||
/*}}}*/
|
||||
@@ -93,19 +92,18 @@ bool pkgDirStream::FinishedFile(Item &Itm,int Fd)
|
||||
{
|
||||
if (Fd < 0)
|
||||
return true;
|
||||
|
||||
if (close(Fd) != 0)
|
||||
return _error->Errno("close",_("Failed to close file %s"),Itm.Name);
|
||||
|
||||
/* Set the modification times. The only way it can fail is if someone
|
||||
has futzed with our file, which is intolerable :> */
|
||||
struct utimbuf Time;
|
||||
Time.actime = Itm.MTime;
|
||||
Time.modtime = Itm.MTime;
|
||||
if (utime(Itm.Name,&Time) != 0)
|
||||
_error->Errno("utime",_("Failed to close file %s"),Itm.Name);
|
||||
|
||||
return true;
|
||||
struct timespec times[2];
|
||||
times[0].tv_sec = times[1].tv_sec = Itm.MTime;
|
||||
times[0].tv_nsec = times[1].tv_nsec = 0;
|
||||
if (futimens(Fd, times) != 0)
|
||||
_error->Errno("futimens", "Failed to set modification time for %s",Itm.Name);
|
||||
|
||||
if (close(Fd) != 0)
|
||||
return _error->Errno("close",_("Failed to close file %s"),Itm.Name);
|
||||
return true;
|
||||
}
|
||||
/*}}}*/
|
||||
// DirStream::Fail - Failed processing a file /*{{{*/
|
||||
|
||||
@@ -319,7 +319,7 @@ bool CreateDirectory(string const &Parent, string const &Path)
|
||||
return false;
|
||||
|
||||
// we are not going to create directories "into the blue"
|
||||
if (Path.find(Parent, 0) != 0)
|
||||
if (Path.compare(0, Parent.length(), Parent) != 0)
|
||||
return false;
|
||||
|
||||
vector<string> const dirs = VectorizeString(Path.substr(Parent.size()), '/');
|
||||
|
||||
@@ -260,8 +260,7 @@ bool SplitClearSignedFile(std::string const &InFile, FileFd * const ContentFile,
|
||||
|
||||
char *buf = NULL;
|
||||
size_t buf_size = 0;
|
||||
ssize_t line_len = 0;
|
||||
while ((line_len = getline(&buf, &buf_size, in)) != -1)
|
||||
while (getline(&buf, &buf_size, in) != -1)
|
||||
{
|
||||
_strrstrip(buf);
|
||||
if (found_message_start == false)
|
||||
@@ -355,7 +354,7 @@ bool OpenMaybeClearSignedFile(std::string const &ClearSignedFileName, FileFd &Me
|
||||
return _error->Error("Couldn't open temporary file to work with %s", ClearSignedFileName.c_str());
|
||||
|
||||
_error->PushToStack();
|
||||
bool const splitDone = SplitClearSignedFile(ClearSignedFileName.c_str(), &MessageFile, NULL, NULL);
|
||||
bool const splitDone = SplitClearSignedFile(ClearSignedFileName, &MessageFile, NULL, NULL);
|
||||
bool const errorDone = _error->PendingError();
|
||||
_error->MergeWithStack();
|
||||
if (splitDone == false)
|
||||
|
||||
@@ -129,13 +129,12 @@ bool Hashes::AddFD(int const Fd,unsigned long long Size, bool const addMD5,
|
||||
bool const addSHA1, bool const addSHA256, bool const addSHA512)
|
||||
{
|
||||
unsigned char Buf[64*64];
|
||||
ssize_t Res = 0;
|
||||
int ToEOF = (Size == 0);
|
||||
bool const ToEOF = (Size == 0);
|
||||
while (Size != 0 || ToEOF)
|
||||
{
|
||||
unsigned long long n = sizeof(Buf);
|
||||
if (!ToEOF) n = std::min(Size, n);
|
||||
Res = read(Fd,Buf,n);
|
||||
ssize_t const Res = read(Fd,Buf,n);
|
||||
if (Res < 0 || (!ToEOF && Res != (ssize_t) n)) // error, or short read
|
||||
return false;
|
||||
if (ToEOF && Res == 0) // EOF
|
||||
|
||||
@@ -9,13 +9,12 @@
|
||||
/* */
|
||||
bool SummationImplementation::AddFD(int const Fd, unsigned long long Size) {
|
||||
unsigned char Buf[64 * 64];
|
||||
ssize_t Res = 0;
|
||||
int ToEOF = (Size == 0);
|
||||
bool const ToEOF = (Size == 0);
|
||||
while (Size != 0 || ToEOF)
|
||||
{
|
||||
unsigned long long n = sizeof(Buf);
|
||||
if (!ToEOF) n = std::min(Size, n);
|
||||
Res = read(Fd, Buf, n);
|
||||
ssize_t const Res = read(Fd, Buf, n);
|
||||
if (Res < 0 || (!ToEOF && Res != (ssize_t) n)) // error, or short read
|
||||
return false;
|
||||
if (ToEOF && Res == 0) // EOF
|
||||
@@ -27,7 +26,7 @@ bool SummationImplementation::AddFD(int const Fd, unsigned long long Size) {
|
||||
}
|
||||
bool SummationImplementation::AddFD(FileFd &Fd, unsigned long long Size) {
|
||||
unsigned char Buf[64 * 64];
|
||||
bool ToEOF = (Size == 0);
|
||||
bool const ToEOF = (Size == 0);
|
||||
while (Size != 0 || ToEOF)
|
||||
{
|
||||
unsigned long long n = sizeof(Buf);
|
||||
|
||||
@@ -568,7 +568,6 @@ void pkgDPkgPM::ProcessDpkgStatusLine(char *line)
|
||||
std::string prefix = APT::String::Strip(list[0]);
|
||||
std::string pkgname;
|
||||
std::string action;
|
||||
ostringstream status;
|
||||
|
||||
// "processing" has the form "processing: action: pkg or trigger"
|
||||
// with action = ["install", "configure", "remove", "purge", "disappear",
|
||||
@@ -1652,7 +1651,7 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
|
||||
io_errors.push_back(string("failed in write on buffer copy for %s"));
|
||||
io_errors.push_back(string("short read on buffer copy for %s"));
|
||||
|
||||
for (vector<string>::iterator I = io_errors.begin(); I != io_errors.end(); I++)
|
||||
for (vector<string>::iterator I = io_errors.begin(); I != io_errors.end(); ++I)
|
||||
{
|
||||
vector<string> list = VectorizeString(dgettext("dpkg", (*I).c_str()), '%');
|
||||
if (list.size() > 1) {
|
||||
@@ -1767,13 +1766,11 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
|
||||
string histfile_name = _config->FindFile("Dir::Log::History");
|
||||
if (!histfile_name.empty())
|
||||
{
|
||||
FILE *log = NULL;
|
||||
char buf[1024];
|
||||
|
||||
fprintf(report, "DpkgHistoryLog:\n");
|
||||
log = fopen(histfile_name.c_str(),"r");
|
||||
FILE* log = fopen(histfile_name.c_str(),"r");
|
||||
if(log != NULL)
|
||||
{
|
||||
char buf[1024];
|
||||
while( fgets(buf, sizeof(buf), log) != NULL)
|
||||
fprintf(report, " %s", buf);
|
||||
fclose(log);
|
||||
|
||||
@@ -242,7 +242,7 @@ PackageManagerFancy::~PackageManagerFancy()
|
||||
void PackageManagerFancy::staticSIGWINCH(int signum)
|
||||
{
|
||||
std::vector<PackageManagerFancy *>::const_iterator I;
|
||||
for(I = instances.begin(); I != instances.end(); I++)
|
||||
for(I = instances.begin(); I != instances.end(); ++I)
|
||||
(*I)->HandleSIGWINCH(signum);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class PackageNameMatcher : public Matcher /*{{{*/
|
||||
public:
|
||||
PackageNameMatcher(const char **patterns)
|
||||
{
|
||||
for(int i=0; patterns[i] != NULL; i++)
|
||||
for(int i=0; patterns[i] != NULL; ++i)
|
||||
{
|
||||
std::string pattern = patterns[i];
|
||||
#ifdef PACKAGE_MATCHER_ABI_COMPAT
|
||||
@@ -79,12 +79,12 @@ class PackageNameMatcher : public Matcher /*{{{*/
|
||||
}
|
||||
virtual ~PackageNameMatcher()
|
||||
{
|
||||
for(J=filters.begin(); J != filters.end(); J++)
|
||||
for(J=filters.begin(); J != filters.end(); ++J)
|
||||
delete *J;
|
||||
}
|
||||
virtual bool operator () (const pkgCache::PkgIterator &P)
|
||||
{
|
||||
for(J=filters.begin(); J != filters.end(); J++)
|
||||
for(J=filters.begin(); J != filters.end(); ++J)
|
||||
{
|
||||
APT::CacheFilter::PackageMatcher *cachefilter = *J;
|
||||
if((*cachefilter)(P))
|
||||
@@ -104,7 +104,7 @@ void ListAllVersions(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/
|
||||
std::ostream &outs)
|
||||
{
|
||||
for (pkgCache::VerIterator Ver = P.VersionList();
|
||||
Ver.end() == false; Ver++)
|
||||
Ver.end() == false; ++Ver)
|
||||
ListSingleVersion(CacheFile, records, Ver, outs);
|
||||
}
|
||||
/*}}}*/
|
||||
@@ -142,7 +142,7 @@ bool List(CommandLine &Cmd)
|
||||
Cache->Head().PackageCount,
|
||||
_("Listing"));
|
||||
GetLocalitySortedVersionSet(CacheFile, bag, matcher, progress);
|
||||
for (LocalitySortedVersionSet::iterator V = bag.begin(); V != bag.end(); V++)
|
||||
for (LocalitySortedVersionSet::iterator V = bag.begin(); V != bag.end(); ++V)
|
||||
{
|
||||
std::stringstream outs;
|
||||
if(_config->FindB("APT::Cmd::All-Versions", false) == true)
|
||||
@@ -159,7 +159,7 @@ bool List(CommandLine &Cmd)
|
||||
|
||||
// FIXME: SORT! and make sorting flexible (alphabetic, by pkg status)
|
||||
// output the sorted map
|
||||
for (K = output_map.begin(); K != output_map.end(); K++)
|
||||
for (K = output_map.begin(); K != output_map.end(); ++K)
|
||||
std::cout << (*K).second << std::endl;
|
||||
|
||||
|
||||
|
||||
@@ -61,18 +61,18 @@ bool FullTextSearch(CommandLine &CmdL) /*{{{*/
|
||||
progress.OverallProgress(50, 100, 50, _("Full Text Search"));
|
||||
progress.SubProgress(bag.size());
|
||||
int Done = 0;
|
||||
for ( ;V != bag.end(); V++)
|
||||
for ( ;V != bag.end(); ++V)
|
||||
{
|
||||
if (Done%500 == 0)
|
||||
progress.Progress(Done);
|
||||
Done++;
|
||||
++Done;
|
||||
|
||||
int i;
|
||||
pkgCache::DescIterator Desc = V.TranslatedDescription();
|
||||
pkgRecords::Parser &parser = records.Lookup(Desc.FileList());
|
||||
|
||||
bool all_found = true;
|
||||
for(i=0; patterns[i] != NULL; i++)
|
||||
for(i=0; patterns[i] != NULL; ++i)
|
||||
{
|
||||
// FIXME: use regexp instead of simple find()
|
||||
const char *pattern = patterns[i];
|
||||
@@ -93,7 +93,7 @@ bool FullTextSearch(CommandLine &CmdL) /*{{{*/
|
||||
|
||||
// FIXME: SORT! and make sorting flexible (alphabetic, by pkg status)
|
||||
// output the sorted map
|
||||
for (K = output_map.begin(); K != output_map.end(); K++)
|
||||
for (K = output_map.begin(); K != output_map.end(); ++K)
|
||||
std::cout << (*K).second << std::endl;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
#include <apt-pkg/error.h>
|
||||
#include <apt-pkg/md5.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <utime.h>
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
|
||||
@@ -234,14 +234,12 @@ bool MultiCompress::Finalize(unsigned long long &OutSize)
|
||||
else
|
||||
{
|
||||
// Update the mtime if necessary
|
||||
if (UpdateMTime > 0 &&
|
||||
if (UpdateMTime > 0 &&
|
||||
(Now - St.st_mtime > (signed)UpdateMTime || St.st_mtime > Now))
|
||||
{
|
||||
struct utimbuf Buf;
|
||||
Buf.actime = Buf.modtime = Now;
|
||||
utime(I->Output.c_str(),&Buf);
|
||||
utimensat(AT_FDCWD, I->Output.c_str(), NULL, AT_SYMLINK_NOFOLLOW);
|
||||
Changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Force the file permissions
|
||||
|
||||
+3
-3
@@ -142,9 +142,9 @@ bool Connect(std::string Host,int Port,const char *Service,int DefPort,int &Fd,
|
||||
// Convert the port name/number
|
||||
char ServStr[300];
|
||||
if (Port != 0)
|
||||
snprintf(ServStr,sizeof(ServStr),"%u",Port);
|
||||
snprintf(ServStr,sizeof(ServStr),"%i", Port);
|
||||
else
|
||||
snprintf(ServStr,sizeof(ServStr),"%s",Service);
|
||||
snprintf(ServStr,sizeof(ServStr),"%s", Service);
|
||||
|
||||
/* We used a cached address record.. Yes this is against the spec but
|
||||
the way we have setup our rotating dns suggests that this is more
|
||||
@@ -190,7 +190,7 @@ bool Connect(std::string Host,int Port,const char *Service,int DefPort,int &Fd,
|
||||
{
|
||||
if (DefPort != 0)
|
||||
{
|
||||
snprintf(ServStr,sizeof(ServStr),"%u",DefPort);
|
||||
snprintf(ServStr, sizeof(ServStr), "%i", DefPort);
|
||||
DefPort = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
+9
-9
@@ -18,7 +18,6 @@
|
||||
#include <apt-pkg/hashes.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <utime.h>
|
||||
#include <unistd.h>
|
||||
#include <apti18n.h>
|
||||
/*}}}*/
|
||||
@@ -71,18 +70,19 @@ bool CopyMethod::Fetch(FetchItem *Itm)
|
||||
}
|
||||
|
||||
From.Close();
|
||||
To.Close();
|
||||
|
||||
|
||||
// Transfer the modification times
|
||||
struct utimbuf TimeBuf;
|
||||
TimeBuf.actime = Buf.st_atime;
|
||||
TimeBuf.modtime = Buf.st_mtime;
|
||||
if (utime(Itm->DestFile.c_str(),&TimeBuf) != 0)
|
||||
struct timespec times[2];
|
||||
times[0].tv_sec = Buf.st_atime;
|
||||
times[1].tv_sec = Buf.st_mtime;
|
||||
times[0].tv_nsec = times[1].tv_nsec = 0;
|
||||
if (futimens(To.Fd(), times) != 0)
|
||||
{
|
||||
To.OpFail();
|
||||
return _error->Errno("utime",_("Failed to set modification time"));
|
||||
return _error->Errno("futimens",_("Failed to set modification time"));
|
||||
}
|
||||
|
||||
To.Close();
|
||||
|
||||
Hashes Hash;
|
||||
FileFd Fd(Res.Filename, FileFd::ReadOnly);
|
||||
Hash.AddFD(Fd);
|
||||
|
||||
+26
-23
@@ -26,7 +26,6 @@
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <utime.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
@@ -953,14 +952,16 @@ void FtpMethod::SigTerm(int)
|
||||
{
|
||||
if (FailFd == -1)
|
||||
_exit(100);
|
||||
close(FailFd);
|
||||
|
||||
|
||||
// Timestamp
|
||||
struct utimbuf UBuf;
|
||||
UBuf.actime = FailTime;
|
||||
UBuf.modtime = FailTime;
|
||||
utime(FailFile.c_str(),&UBuf);
|
||||
|
||||
struct timespec times[2];
|
||||
times[0].tv_sec = FailTime;
|
||||
times[1].tv_sec = FailTime;
|
||||
times[0].tv_nsec = times[1].tv_nsec = 0;
|
||||
futimens(FailFd, times);
|
||||
|
||||
close(FailFd);
|
||||
|
||||
_exit(100);
|
||||
}
|
||||
/*}}}*/
|
||||
@@ -1059,13 +1060,14 @@ bool FtpMethod::Fetch(FetchItem *Itm)
|
||||
if (Server->Get(File,Fd,Res.ResumePoint,Hash,Missing) == false)
|
||||
{
|
||||
Fd.Close();
|
||||
|
||||
|
||||
// Timestamp
|
||||
struct utimbuf UBuf;
|
||||
UBuf.actime = FailTime;
|
||||
UBuf.modtime = FailTime;
|
||||
utime(FailFile.c_str(),&UBuf);
|
||||
|
||||
struct timespec times[2];
|
||||
times[0].tv_sec = FailTime;
|
||||
times[1].tv_sec = FailTime;
|
||||
times[0].tv_nsec = times[1].tv_nsec = 0;
|
||||
futimens(FailFd, times);
|
||||
|
||||
// If the file is missing we hard fail and delete the destfile
|
||||
// otherwise transient fail
|
||||
if (Missing == true) {
|
||||
@@ -1077,20 +1079,21 @@ bool FtpMethod::Fetch(FetchItem *Itm)
|
||||
}
|
||||
|
||||
Res.Size = Fd.Size();
|
||||
|
||||
// Timestamp
|
||||
struct timespec times[2];
|
||||
times[0].tv_sec = FailTime;
|
||||
times[1].tv_sec = FailTime;
|
||||
times[0].tv_nsec = times[1].tv_nsec = 0;
|
||||
futimens(Fd.Fd(), times);
|
||||
FailFd = -1;
|
||||
}
|
||||
|
||||
|
||||
Res.LastModified = FailTime;
|
||||
Res.TakeHashes(Hash);
|
||||
|
||||
// Timestamp
|
||||
struct utimbuf UBuf;
|
||||
UBuf.actime = FailTime;
|
||||
UBuf.modtime = FailTime;
|
||||
utime(Queue->DestFile.c_str(),&UBuf);
|
||||
FailFd = -1;
|
||||
|
||||
URIDone(Res);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
/*}}}*/
|
||||
|
||||
+14
-12
@@ -19,7 +19,6 @@
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <utime.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <apti18n.h>
|
||||
@@ -94,32 +93,35 @@ bool GzipMethod::Fetch(FetchItem *Itm)
|
||||
}
|
||||
|
||||
From.Close();
|
||||
To.Close();
|
||||
|
||||
|
||||
if (Failed == true)
|
||||
return false;
|
||||
|
||||
|
||||
// Transfer the modification times
|
||||
struct stat Buf;
|
||||
if (stat(Path.c_str(),&Buf) != 0)
|
||||
return _error->Errno("stat",_("Failed to stat"));
|
||||
|
||||
struct utimbuf TimeBuf;
|
||||
TimeBuf.actime = Buf.st_atime;
|
||||
TimeBuf.modtime = Buf.st_mtime;
|
||||
if (utime(Itm->DestFile.c_str(),&TimeBuf) != 0)
|
||||
return _error->Errno("utime",_("Failed to set modification time"));
|
||||
struct timespec times[2];
|
||||
times[0].tv_sec = Buf.st_atime;
|
||||
times[1].tv_sec = Buf.st_mtime;
|
||||
times[0].tv_nsec = times[1].tv_nsec = 0;
|
||||
if (futimens(To.Fd(), times) != 0)
|
||||
{
|
||||
To.OpFail();
|
||||
return _error->Errno("futimens",_("Failed to set modification time"));
|
||||
}
|
||||
Res.Size = To.FileSize();
|
||||
To.Close();
|
||||
|
||||
if (stat(Itm->DestFile.c_str(),&Buf) != 0)
|
||||
return _error->Errno("stat",_("Failed to stat"));
|
||||
|
||||
|
||||
// Return a Done response
|
||||
Res.LastModified = Buf.st_mtime;
|
||||
Res.Size = Buf.st_size;
|
||||
Res.TakeHashes(Hash);
|
||||
|
||||
URIDone(Res);
|
||||
|
||||
return true;
|
||||
}
|
||||
/*}}}*/
|
||||
|
||||
+1
-3
@@ -97,8 +97,6 @@ void CircleBuf::Reset()
|
||||
is non-blocking.. */
|
||||
bool CircleBuf::Read(int Fd)
|
||||
{
|
||||
unsigned long long BwReadMax;
|
||||
|
||||
while (1)
|
||||
{
|
||||
// Woops, buffer is full
|
||||
@@ -106,7 +104,7 @@ bool CircleBuf::Read(int Fd)
|
||||
return true;
|
||||
|
||||
// what's left to read in this tick
|
||||
BwReadMax = CircleBuf::BwReadLimit/BW_HZ;
|
||||
unsigned long long const BwReadMax = CircleBuf::BwReadLimit/BW_HZ;
|
||||
|
||||
if(CircleBuf::BwReadLimit) {
|
||||
struct timeval now;
|
||||
|
||||
+5
-5
@@ -21,7 +21,6 @@
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <utime.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
@@ -405,10 +404,11 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
|
||||
curl_easy_getinfo(curl, CURLINFO_FILETIME, &Res.LastModified);
|
||||
if (Res.LastModified != -1)
|
||||
{
|
||||
struct utimbuf UBuf;
|
||||
UBuf.actime = Res.LastModified;
|
||||
UBuf.modtime = Res.LastModified;
|
||||
utime(File->Name().c_str(),&UBuf);
|
||||
struct timespec times[2];
|
||||
times[0].tv_sec = Res.LastModified;
|
||||
times[1].tv_sec = Res.LastModified;
|
||||
times[0].tv_nsec = times[1].tv_nsec = 0;
|
||||
futimens(File->Fd(), times);
|
||||
}
|
||||
else
|
||||
Res.LastModified = resultStat.st_mtime;
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ class HttpsMethod : public pkgAcqMethod
|
||||
public:
|
||||
FileFd *File;
|
||||
|
||||
HttpsMethod() : pkgAcqMethod("1.2",Pipeline | SendConfig)
|
||||
HttpsMethod() : pkgAcqMethod("1.2",Pipeline | SendConfig), File(NULL)
|
||||
{
|
||||
File = 0;
|
||||
curl = curl_easy_init();
|
||||
|
||||
+4
-4
@@ -114,7 +114,7 @@ bool MirrorMethod::Clean(string Dir)
|
||||
for(I=list.begin(); I != list.end(); ++I)
|
||||
{
|
||||
string uri = (*I)->GetURI();
|
||||
if(uri.find("mirror://") != 0)
|
||||
if(uri.compare(0, strlen("mirror://"), "mirror://") != 0)
|
||||
continue;
|
||||
string BaseUri = uri.substr(0,uri.size()-1);
|
||||
if (URItoFileName(BaseUri) == Dir->d_name)
|
||||
@@ -198,9 +198,9 @@ bool MirrorMethod::RandomizeMirrorFile(string mirror_file)
|
||||
// "stable" on the same machine. this is to avoid running into out-of-sync
|
||||
// issues (i.e. Release/Release.gpg different on each mirror)
|
||||
struct utsname buf;
|
||||
int seed=1, i;
|
||||
int seed=1;
|
||||
if(uname(&buf) == 0) {
|
||||
for(i=0,seed=1; buf.nodename[i] != 0; i++) {
|
||||
for(int i=0,seed=1; buf.nodename[i] != 0; ++i) {
|
||||
seed = seed * 31 + buf.nodename[i];
|
||||
}
|
||||
}
|
||||
@@ -306,7 +306,7 @@ bool MirrorMethod::InitMirrors()
|
||||
if (s.size() == 0)
|
||||
continue;
|
||||
// ignore non http lines
|
||||
if (s.find("http://") != 0)
|
||||
if (s.compare(0, strlen("http://"), "http://") != 0)
|
||||
continue;
|
||||
|
||||
AllMirrors.push_back(s);
|
||||
|
||||
+18
-18
@@ -20,7 +20,6 @@
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <utime.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
@@ -395,13 +394,14 @@ void RSHMethod::SigTerm(int sig)
|
||||
{
|
||||
if (FailFd == -1)
|
||||
_exit(100);
|
||||
close(FailFd);
|
||||
|
||||
// Timestamp
|
||||
struct utimbuf UBuf;
|
||||
UBuf.actime = FailTime;
|
||||
UBuf.modtime = FailTime;
|
||||
utime(FailFile.c_str(),&UBuf);
|
||||
// Transfer the modification times
|
||||
struct timespec times[2];
|
||||
times[0].tv_sec = FailTime;
|
||||
times[1].tv_sec = FailTime;
|
||||
times[0].tv_nsec = times[1].tv_nsec = 0;
|
||||
futimens(FailFd, times);
|
||||
close(FailFd);
|
||||
|
||||
_exit(100);
|
||||
}
|
||||
@@ -488,10 +488,11 @@ bool RSHMethod::Fetch(FetchItem *Itm)
|
||||
Fd.Close();
|
||||
|
||||
// Timestamp
|
||||
struct utimbuf UBuf;
|
||||
UBuf.actime = FailTime;
|
||||
UBuf.modtime = FailTime;
|
||||
utime(FailFile.c_str(),&UBuf);
|
||||
struct timespec times[2];
|
||||
times[0].tv_sec = FailTime;
|
||||
times[1].tv_sec = FailTime;
|
||||
times[0].tv_nsec = times[1].tv_nsec = 0;
|
||||
futimens(FailFd, times);
|
||||
|
||||
// If the file is missing we hard fail otherwise transient fail
|
||||
if (Missing == true)
|
||||
@@ -501,18 +502,17 @@ bool RSHMethod::Fetch(FetchItem *Itm)
|
||||
}
|
||||
|
||||
Res.Size = Fd.Size();
|
||||
struct timespec times[2];
|
||||
times[0].tv_sec = FailTime;
|
||||
times[1].tv_sec = FailTime;
|
||||
times[0].tv_nsec = times[1].tv_nsec = 0;
|
||||
futimens(Fd.Fd(), times);
|
||||
FailFd = -1;
|
||||
}
|
||||
|
||||
Res.LastModified = FailTime;
|
||||
Res.TakeHashes(Hash);
|
||||
|
||||
// Timestamp
|
||||
struct utimbuf UBuf;
|
||||
UBuf.actime = FailTime;
|
||||
UBuf.modtime = FailTime;
|
||||
utime(Queue->DestFile.c_str(),&UBuf);
|
||||
FailFd = -1;
|
||||
|
||||
URIDone(Res);
|
||||
|
||||
return true;
|
||||
|
||||
+12
-13
@@ -17,9 +17,9 @@
|
||||
#include <apt-pkg/hashes.h>
|
||||
#include <apt-pkg/netrc.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <utime.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
@@ -368,14 +368,14 @@ void ServerMethod::SigTerm(int)
|
||||
{
|
||||
if (FailFd == -1)
|
||||
_exit(100);
|
||||
|
||||
struct timespec times[2];
|
||||
times[0].tv_sec = FailTime;
|
||||
times[1].tv_sec = FailTime;
|
||||
times[0].tv_nsec = times[1].tv_nsec = 0;
|
||||
futimens(FailFd, times);
|
||||
close(FailFd);
|
||||
|
||||
// Timestamp
|
||||
struct utimbuf UBuf;
|
||||
UBuf.actime = FailTime;
|
||||
UBuf.modtime = FailTime;
|
||||
utime(FailFile.c_str(),&UBuf);
|
||||
|
||||
|
||||
_exit(100);
|
||||
}
|
||||
/*}}}*/
|
||||
@@ -539,11 +539,10 @@ int ServerMethod::Loop()
|
||||
File = 0;
|
||||
|
||||
// Timestamp
|
||||
struct utimbuf UBuf;
|
||||
time(&UBuf.actime);
|
||||
UBuf.actime = Server->Date;
|
||||
UBuf.modtime = Server->Date;
|
||||
utime(Queue->DestFile.c_str(),&UBuf);
|
||||
struct timespec times[2];
|
||||
times[0].tv_sec = times[1].tv_sec = Server->Date;
|
||||
times[0].tv_nsec = times[1].tv_nsec = 0;
|
||||
utimensat(AT_FDCWD, Queue->DestFile.c_str(), times, AT_SYMLINK_NOFOLLOW);
|
||||
|
||||
// Send status to APT
|
||||
if (Result == true)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user