summaryrefslogtreecommitdiff
path: root/apt-pkg/cachefile.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-11-02 18:49:52 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2015-11-04 18:42:28 +0100
commitce1f3a2c616b86da657c1c796efa5f4d18c30c39 (patch)
tree5ab1f87a06042576c479e4064b47252f9956e656 /apt-pkg/cachefile.cc
parentcd46d4ebd33e74ee53bbc73dcdb7fe1d4d006558 (diff)
wrap every unlink call to check for != /dev/null
Unlinking /dev/null is bad, we shouldn't do that. Also, we should print at least a warning if we tried to unlink a file but didn't manage to pull it of (ignoring the case were the file is /dev/null or doesn't exist in the first place). This got triggered by a relatively unlikely to cause problem in pkgAcquire::Worker::PrepareFiles which would while temporary uncompressed files (which are set to keep compressed) figure out that to files are the same and prepare for sharing by deleting them. Bad move. That also shows why not printing a warning is a bad idea as this hide the error for in non-root test runs. Git-Dch: Ignore
Diffstat (limited to 'apt-pkg/cachefile.cc')
-rw-r--r--apt-pkg/cachefile.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc
index 1c9bc694b..aaa2436c5 100644
--- a/apt-pkg/cachefile.cc
+++ b/apt-pkg/cachefile.cc
@@ -191,9 +191,9 @@ void pkgCacheFile::RemoveCaches()
std::string const srcpkgcache = _config->FindFile("Dir::cache::srcpkgcache");
if (pkgcache.empty() == false && RealFileExists(pkgcache) == true)
- unlink(pkgcache.c_str());
+ RemoveFile("RemoveCaches", pkgcache);
if (srcpkgcache.empty() == false && RealFileExists(srcpkgcache) == true)
- unlink(srcpkgcache.c_str());
+ RemoveFile("RemoveCaches", srcpkgcache);
if (pkgcache.empty() == false)
{
std::string cachedir = flNotFile(pkgcache);
@@ -207,7 +207,7 @@ void pkgCacheFile::RemoveCaches()
std::string nuke = flNotDir(*file);
if (strncmp(cachefile.c_str(), nuke.c_str(), cachefile.length()) != 0)
continue;
- unlink(file->c_str());
+ RemoveFile("RemoveCaches", *file);
}
}
}
@@ -226,7 +226,7 @@ void pkgCacheFile::RemoveCaches()
std::string nuke = flNotDir(*file);
if (strncmp(cachefile.c_str(), nuke.c_str(), cachefile.length()) != 0)
continue;
- unlink(file->c_str());
+ RemoveFile("RemoveCaches", *file);
}
}
/*}}}*/