From 9995c4a0bc2d8567ff9f11d338ad610754682372 Mon Sep 17 00:00:00 2001 From: Ishan Jayawardena Date: Mon, 13 Jun 2011 15:16:14 +0530 Subject: added support for downloading debdelta files and queuing successfully downloaded debdeltas for processing with the debdelta apt method, in apt-pkg/acquire-item.{cc,h} in pkgAcqArchive class. Currently, no index for deltas are used. Proper progress reporting and methods to verify the debdeltas are yet to be added. --- apt-pkg/contrib/fileutl.cc | 23 ++++++++++++++++++++--- apt-pkg/contrib/fileutl.h | 1 + apt-pkg/contrib/strutl.cc | 6 +++++- 3 files changed, 26 insertions(+), 4 deletions(-) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 50019872e..b1724971f 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -148,7 +148,8 @@ bool CopyFile(FileFd &From,FileFd &To) return true; } - /*}}}*/ + +/*}}}*/ // GetLock - Gets a lock file /*{{{*/ // --------------------------------------------------------------------- /* This will create an empty file of the given name and lock it. Once this @@ -275,7 +276,22 @@ bool CreateDirectory(string const &Parent, string const &Path) } return true; } - /*}}}*/ + +// Rename - Rename a file /*{{{*/ +// --------------------------------------------------------------------- +/* This helper function is used by alot of item methods as thier final + step */ +bool Rename(string From, string To) +{ + if (rename(From.c_str(),To.c_str()) != 0) + { + return _error->Error("Rename failed. %s (%s -> %s).",strerror(errno), + From.c_str(),To.c_str()); + } + return true; +} + +/*}}}*/ // CreateAPTDirectoryIfNeeded - ensure that the given directory exists /*{{{*/ // --------------------------------------------------------------------- /* a small wrapper around CreateDirectory to check if it exists and to @@ -571,6 +587,7 @@ void SetNonBlock(int Fd,bool Block) in seconds. */ bool WaitFd(int Fd,bool write,unsigned long timeout) { + //std::cerr << "WaitFd()" << std::endl; fd_set Set; struct timeval tv; FD_ZERO(&Set); @@ -601,7 +618,7 @@ bool WaitFd(int Fd,bool write,unsigned long timeout) if (Res <= 0) return false; } - + //std::cerr << " waited for FD " << Fd << std::endl; return true; } /*}}}*/ diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index cde288ad2..7c1127798 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -97,6 +97,7 @@ bool FileExists(string File); bool RealFileExists(string File); bool DirectoryExists(string const &Path) __attrib_const; bool CreateDirectory(string const &Parent, string const &Path); +bool Rename(string From, string To); /** \brief Ensure the existence of the given Path * diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 072dda3ac..a452f65f3 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -442,6 +442,7 @@ std::string OutputInDepth(const unsigned long Depth, const char* Separator) string URItoFileName(const string &URI) { // Nuke 'sensitive' items + //std::cerr << "\n>>>>URItoFileName():\n URI: " << URI << std::endl; ::URI U(URI); U.User.clear(); U.Password.clear(); @@ -450,6 +451,7 @@ string URItoFileName(const string &URI) // "\x00-\x20{}|\\\\^\\[\\]<>\"\x7F-\xFF"; string NewURI = QuoteString(U,"\\|{}[]<>\"^~_=!@#$%^&*"); replace(NewURI.begin(),NewURI.end(),'/','_'); + //std::cerr << " NewUri: " << NewURI << std::endl; return NewURI; } /*}}}*/ @@ -723,6 +725,7 @@ string TimeRFC1123(time_t Date) */ bool ReadMessages(int Fd, vector &List) { + //std::cerr << "ReadMessages() Reading from Fd " << Fd << std::endl; char Buffer[64000]; char *End = Buffer; // Represents any left-over from the previous iteration of the @@ -765,6 +768,7 @@ bool ReadMessages(int Fd, vector &List) I = Buffer; List.push_back(PartialMessage); + //std::cerr << " pushed back message:" << PartialMessage << std::endl; PartialMessage.clear(); } if (End != Buffer) @@ -790,7 +794,7 @@ bool ReadMessages(int Fd, vector &List) // -- dburrows 2008-04-02 return true; } - + //std::cerr << " calling WaidFd again." << std::endl; if (WaitFd(Fd) == false) return false; } -- cgit v1.2.3