#include <fcntl.h>
#include <sys/vfs.h>
#include <sys/statvfs.h>
+#include <sys/stat.h>
#include <errno.h>
#include <apti18n.h>
std::ifstream src((*I)->DestFile.c_str(), std::ios::binary);
std::ofstream dst(filename.c_str(), std::ios::binary);
dst << src.rdbuf();
+ chmod(filename.c_str(), 0644);
}
}
return Failed == false;
}
pkgAcquire Fetcher;
- Fetcher.GetLock(archivedir);
- Fetcher.Clean(archivedir);
- Fetcher.Clean(archivedir + "partial/");
+ if (archivedir.empty() == false && FileExists(archivedir) == true &&
+ Fetcher.GetLock(archivedir) == true)
+ {
+ Fetcher.Clean(archivedir);
+ Fetcher.Clean(archivedir + "partial/");
+ }
- Fetcher.GetLock(listsdir);
- Fetcher.Clean(listsdir + "partial/");
+ if (listsdir.empty() == false && FileExists(listsdir) == true &&
+ Fetcher.GetLock(listsdir) == true)
+ {
+ Fetcher.Clean(listsdir + "partial/");
+ }
pkgCacheFile::RemoveCaches();
};
bool DoAutoClean(CommandLine &)
{
+ std::string const archivedir = _config->FindDir("Dir::Cache::Archives");
+ if (FileExists(archivedir) == false)
+ return true;
+
// Lock the archive directory
FileFd Lock;
if (_config->FindB("Debug::NoLocking",false) == false)
{
- int lock_fd = GetLock(_config->FindDir("Dir::Cache::Archives") + "lock");
+ int lock_fd = GetLock(flCombine(archivedir, "lock"));
if (lock_fd < 0)
return _error->Error(_("Unable to lock the download directory"));
Lock.Fd(lock_fd);
LogCleaner Cleaner;
- return Cleaner.Go(_config->FindDir("Dir::Cache::archives"),*Cache) &&
- Cleaner.Go(_config->FindDir("Dir::Cache::archives") + "partial/",*Cache);
+ return Cleaner.Go(archivedir, *Cache) &&
+ Cleaner.Go(flCombine(archivedir, "partial/"), *Cache);
}
/*}}}*/