Ignore empty packages within the cache dir

Those are most likely leftovers from  previous failed download attempts and
can be ignored. (Existing files are overridden.)
This commit is contained in:
Martchus 2021-07-17 19:57:37 +02:00
parent e5f4057c61
commit bbc7c3a533
1 changed files with 3 additions and 4 deletions

View File

@ -133,14 +133,13 @@ void ReloadLibraryDependencies::run()
const auto &arch = packageInfo->arch;
if (!db->localPkgDir.empty()) {
path = db->localPkgDir % '/' + fileName;
} else if (std::filesystem::exists(cachePath = cacheDir + fileName, ec)) {
} else if (std::filesystem::file_size(cachePath = cacheDir + fileName, ec) && !ec) {
path = std::move(cachePath);
} else if (std::filesystem::exists(cachePath = cacheDir % arch % '/' + fileName, ec)) {
} else if (std::filesystem::file_size(cachePath = cacheDir % arch % '/' + fileName, ec) && !ec) {
path = std::move(cachePath);
} else {
for (const auto &possibleCachePath : m_setup.config.packageCacheDirs) {
std::error_code ecFileExists;
if (std::filesystem::exists(path = possibleCachePath % '/' + fileName, ecFileExists)) {
if (std::filesystem::file_size(path = possibleCachePath % '/' + fileName, ec) && !ec) {
break;
}
path.clear();