|
|
@@ -65,7 +65,7 @@ static void printHashSumComparision(std::string const &URI, HashStringList const
|
|
|
std::cerr << "\t- " << hs->toStr() << std::endl;
|
|
|
}
|
|
|
/*}}}*/
|
|
|
-static void changeOwnerAndPermissionOfFile(char const * const requester, char const * const file, char const * const user, char const * const group, mode_t const mode)
|
|
|
+static void ChangeOwnerAndPermissionOfFile(char const * const requester, char const * const file, char const * const user, char const * const group, mode_t const mode)
|
|
|
{
|
|
|
// ensure the file is owned by root and has good permissions
|
|
|
struct passwd const * const pw = getpwnam(user);
|
|
|
@@ -78,15 +78,15 @@ static void changeOwnerAndPermissionOfFile(char const * const requester, char co
|
|
|
if (chmod(file, mode) != 0)
|
|
|
_error->WarningE(requester, "chmod 0%o of file %s failed", mode, file);
|
|
|
}
|
|
|
-static std::string preparePartialFile(std::string const &file)
|
|
|
+static std::string GetPartialFileName(std::string const &file)
|
|
|
{
|
|
|
std::string DestFile = _config->FindDir("Dir::State::lists") + "partial/";
|
|
|
DestFile += file;
|
|
|
return DestFile;
|
|
|
}
|
|
|
-static std::string preparePartialFileFromURI(std::string const &uri)
|
|
|
+static std::string GetPartialFileNameFromURI(std::string const &uri)
|
|
|
{
|
|
|
- return preparePartialFile(URItoFileName(uri));
|
|
|
+ return GetPartialFileName(URItoFileName(uri));
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -211,7 +211,7 @@ bool pkgAcquire::Item::Rename(string From,string To)
|
|
|
void pkgAcquire::Item::QueueURI(ItemDesc &Item)
|
|
|
{
|
|
|
if (RealFileExists(DestFile))
|
|
|
- changeOwnerAndPermissionOfFile("preparePartialFile", DestFile.c_str(), "_apt", "root", 0600);
|
|
|
+ ChangeOwnerAndPermissionOfFile("GetPartialFileName", DestFile.c_str(), "_apt", "root", 0600);
|
|
|
Owner->Enqueue(Item);
|
|
|
}
|
|
|
void pkgAcquire::Item::Dequeue()
|
|
|
@@ -334,7 +334,7 @@ pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire *Owner,
|
|
|
Desc.ShortDesc = Target->ShortDesc;
|
|
|
Desc.URI = Target->URI + ".diff/Index";
|
|
|
|
|
|
- DestFile = preparePartialFileFromURI(Desc.URI);
|
|
|
+ DestFile = GetPartialFileNameFromURI(Desc.URI);
|
|
|
|
|
|
if(Debug)
|
|
|
std::clog << "pkgAcqDiffIndex: " << Desc.URI << std::endl;
|
|
|
@@ -494,7 +494,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile) /*{{{*/
|
|
|
{
|
|
|
// FIXME: make this use the method
|
|
|
PackagesFileReadyInPartial = true;
|
|
|
- std::string const Partial = preparePartialFileFromURI(RealURI);
|
|
|
+ std::string const Partial = GetPartialFileNameFromURI(RealURI);
|
|
|
|
|
|
FileFd From(CurrentPackagesFile, FileFd::ReadOnly);
|
|
|
FileFd To(Partial, FileFd::WriteEmpty);
|
|
|
@@ -623,7 +623,7 @@ pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner,
|
|
|
: pkgAcqBaseIndex(Owner, TransactionManager, Target, ExpectedHashes, MetaIndexParser),
|
|
|
available_patches(diffs), ServerSha1(ServerSha1)
|
|
|
{
|
|
|
- DestFile = preparePartialFileFromURI(Target->URI);
|
|
|
+ DestFile = GetPartialFileNameFromURI(Target->URI);
|
|
|
|
|
|
Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
|
|
|
|
|
|
@@ -676,7 +676,7 @@ void pkgAcqIndexDiffs::Finish(bool allDone)
|
|
|
}
|
|
|
|
|
|
// queue for copy
|
|
|
- PartialFile = preparePartialFileFromURI(RealURI);
|
|
|
+ PartialFile = GetPartialFileNameFromURI(RealURI);
|
|
|
|
|
|
DestFile = _config->FindDir("Dir::State::lists");
|
|
|
DestFile += URItoFileName(RealURI);
|
|
|
@@ -707,7 +707,7 @@ void pkgAcqIndexDiffs::Finish(bool allDone)
|
|
|
bool pkgAcqIndexDiffs::QueueNextDiff() /*{{{*/
|
|
|
{
|
|
|
// calc sha1 of the just patched file
|
|
|
- std::string const FinalFile = preparePartialFileFromURI(RealURI);
|
|
|
+ std::string const FinalFile = GetPartialFileNameFromURI(RealURI);
|
|
|
|
|
|
if(!FileExists(FinalFile))
|
|
|
{
|
|
|
@@ -752,7 +752,7 @@ bool pkgAcqIndexDiffs::QueueNextDiff() /*{{{*/
|
|
|
// queue the right diff
|
|
|
Desc.URI = RealURI + ".diff/" + available_patches[0].file + ".gz";
|
|
|
Desc.Description = Description + " " + available_patches[0].file + string(".pdiff");
|
|
|
- DestFile = preparePartialFileFromURI(RealURI + ".diff/" + available_patches[0].file);
|
|
|
+ DestFile = GetPartialFileNameFromURI(RealURI + ".diff/" + available_patches[0].file);
|
|
|
|
|
|
if(Debug)
|
|
|
std::clog << "pkgAcqIndexDiffs::QueueNextDiff(): " << Desc.URI << std::endl;
|
|
|
@@ -771,7 +771,7 @@ void pkgAcqIndexDiffs::Done(string Message,unsigned long long Size, HashStringLi
|
|
|
Item::Done(Message, Size, Hashes, Cnf);
|
|
|
|
|
|
// FIXME: verify this download too before feeding it to rred
|
|
|
- std::string const FinalFile = preparePartialFileFromURI(RealURI);
|
|
|
+ std::string const FinalFile = GetPartialFileNameFromURI(RealURI);
|
|
|
|
|
|
// success in downloading a diff, enter ApplyDiff state
|
|
|
if(State == StateFetchDiff)
|
|
|
@@ -842,7 +842,7 @@ pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire *Owner,
|
|
|
Desc.URI = RealURI + ".diff/" + patch.file + ".gz";
|
|
|
Desc.Description = Description + " " + patch.file + string(".pdiff");
|
|
|
|
|
|
- DestFile = preparePartialFileFromURI(RealURI + ".diff/" + patch.file);
|
|
|
+ DestFile = GetPartialFileNameFromURI(RealURI + ".diff/" + patch.file);
|
|
|
|
|
|
if(Debug)
|
|
|
std::clog << "pkgAcqIndexMergeDiffs: " << Desc.URI << std::endl;
|
|
|
@@ -880,7 +880,7 @@ void pkgAcqIndexMergeDiffs::Done(string Message,unsigned long long Size,HashStri
|
|
|
Item::Done(Message,Size,Hashes,Cnf);
|
|
|
|
|
|
// FIXME: verify download before feeding it to rred
|
|
|
- string const FinalFile = preparePartialFileFromURI(RealURI);
|
|
|
+ string const FinalFile = GetPartialFileNameFromURI(RealURI);
|
|
|
|
|
|
if (State == StateFetchDiff)
|
|
|
{
|
|
|
@@ -936,7 +936,7 @@ void pkgAcqIndexMergeDiffs::Done(string Message,unsigned long long Size,HashStri
|
|
|
for (std::vector<pkgAcqIndexMergeDiffs *>::const_iterator I = allPatches->begin();
|
|
|
I != allPatches->end(); ++I)
|
|
|
{
|
|
|
- std::string const PartialFile = preparePartialFileFromURI(RealURI);
|
|
|
+ std::string const PartialFile = GetPartialFileNameFromURI(RealURI);
|
|
|
std::string patch = PartialFile + ".ed." + (*I)->patch.file + ".gz";
|
|
|
std::cerr << patch << std::endl;
|
|
|
unlink(patch.c_str());
|
|
|
@@ -1034,7 +1034,7 @@ void pkgAcqIndex::Init(string const &URI, string const &URIDesc,
|
|
|
{
|
|
|
Stage = STAGE_DOWNLOAD;
|
|
|
|
|
|
- DestFile = preparePartialFileFromURI(URI);
|
|
|
+ DestFile = GetPartialFileNameFromURI(URI);
|
|
|
|
|
|
CurrentCompressionExtension = CompressionExtensions.substr(0, CompressionExtensions.find(' '));
|
|
|
if (CurrentCompressionExtension == "uncompressed")
|
|
|
@@ -1151,7 +1151,7 @@ void pkgAcqIndex::ReverifyAfterIMS()
|
|
|
{
|
|
|
// update destfile to *not* include the compression extension when doing
|
|
|
// a reverify (as its uncompressed on disk already)
|
|
|
- DestFile = preparePartialFileFromURI(RealURI);
|
|
|
+ DestFile = GetPartialFileNameFromURI(RealURI);
|
|
|
|
|
|
// adjust DestFile if its compressed on disk
|
|
|
if (_config->FindB("Acquire::GzipIndexes",false) == true)
|
|
|
@@ -1277,7 +1277,7 @@ void pkgAcqIndex::StageDownloadDone(string Message,
|
|
|
// If we have compressed indexes enabled, queue for hash verification
|
|
|
if (_config->FindB("Acquire::GzipIndexes",false))
|
|
|
{
|
|
|
- DestFile = preparePartialFileFromURI(RealURI + '.' + CurrentCompressionExtension);
|
|
|
+ DestFile = GetPartialFileNameFromURI(RealURI + '.' + CurrentCompressionExtension);
|
|
|
EraseFileName = "";
|
|
|
Stage = STAGE_DECOMPRESS_AND_VERIFY;
|
|
|
Desc.URI = "copy:" + FileName;
|
|
|
@@ -1414,7 +1414,7 @@ void pkgAcqMetaBase::AbortTransaction()
|
|
|
(*I)->Status = pkgAcquire::Item::StatDone;
|
|
|
|
|
|
// kill files in partial
|
|
|
- std::string const PartialFile = preparePartialFile(flNotDir((*I)->DestFile));
|
|
|
+ std::string const PartialFile = GetPartialFileName(flNotDir((*I)->DestFile));
|
|
|
if(FileExists(PartialFile))
|
|
|
Rename(PartialFile, PartialFile + ".FAILED");
|
|
|
}
|
|
|
@@ -1450,7 +1450,7 @@ void pkgAcqMetaBase::CommitTransaction()
|
|
|
<< (*I)->DescURI() << std::endl;
|
|
|
|
|
|
Rename((*I)->PartialFile, (*I)->DestFile);
|
|
|
- changeOwnerAndPermissionOfFile("CommitTransaction", (*I)->DestFile.c_str(), "root", "root", 0644);
|
|
|
+ ChangeOwnerAndPermissionOfFile("CommitTransaction", (*I)->DestFile.c_str(), "root", "root", 0644);
|
|
|
|
|
|
} else {
|
|
|
if(_config->FindB("Debug::Acquire::Transaction", false) == true)
|
|
|
@@ -1641,7 +1641,7 @@ void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf)/*{{{*/
|
|
|
|
|
|
// this ensures that any file in the lists/ dir is removed by the
|
|
|
// transaction
|
|
|
- DestFile = preparePartialFileFromURI(RealURI);
|
|
|
+ DestFile = GetPartialFileNameFromURI(RealURI);
|
|
|
TransactionManager->TransactionStageRemoval(this, DestFile);
|
|
|
|
|
|
// only allow going further if the users explicitely wants it
|
|
|
@@ -1697,7 +1697,7 @@ pkgAcqMetaIndex::pkgAcqMetaIndex(pkgAcquire *Owner, /*{{{*/
|
|
|
// pkgAcqMetaIndex::Init - Delayed constructor /*{{{*/
|
|
|
void pkgAcqMetaIndex::Init(std::string URIDesc, std::string ShortDesc)
|
|
|
{
|
|
|
- DestFile = preparePartialFileFromURI(RealURI);
|
|
|
+ DestFile = GetPartialFileNameFromURI(RealURI);
|
|
|
|
|
|
// Create the item
|
|
|
Desc.Description = URIDesc;
|
|
|
@@ -2349,7 +2349,7 @@ bool pkgAcqArchive::QueueNext()
|
|
|
else
|
|
|
{
|
|
|
PartialSize = Buf.st_size;
|
|
|
- changeOwnerAndPermissionOfFile("pkgAcqArchive::QueueNext", FinalFile.c_str(), "_apt", "root", 0600);
|
|
|
+ ChangeOwnerAndPermissionOfFile("pkgAcqArchive::QueueNext", FinalFile.c_str(), "_apt", "root", 0600);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2419,7 +2419,7 @@ void pkgAcqArchive::Done(string Message,unsigned long long Size, HashStringList
|
|
|
string FinalFile = _config->FindDir("Dir::Cache::Archives");
|
|
|
FinalFile += flNotDir(StoreFilename);
|
|
|
Rename(DestFile,FinalFile);
|
|
|
- changeOwnerAndPermissionOfFile("pkgAcqArchive::Done", FinalFile.c_str(), "root", "root", 0644);
|
|
|
+ ChangeOwnerAndPermissionOfFile("pkgAcqArchive::Done", FinalFile.c_str(), "root", "root", 0644);
|
|
|
StoreFilename = DestFile = FinalFile;
|
|
|
Complete = true;
|
|
|
}
|
|
|
@@ -2517,7 +2517,7 @@ pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI, HashStringList const &Hashe
|
|
|
else
|
|
|
{
|
|
|
PartialSize = Buf.st_size;
|
|
|
- changeOwnerAndPermissionOfFile("pkgAcqFile", DestFile.c_str(), "_apt", "root", 0600);
|
|
|
+ ChangeOwnerAndPermissionOfFile("pkgAcqFile", DestFile.c_str(), "_apt", "root", 0600);
|
|
|
}
|
|
|
}
|
|
|
|