aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-07-04 18:50:50 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:39:58 +0200
commitbca6bb2d6e00188c516c91d38ff8a67d0544cf22 (patch)
tree522ab2938ec5ea8e83a8655ac80f8e9467ca01fc
parent8fce4815e2b1cb275b5b67af438a98ce1f1fc5f8 (diff)
Add check that the package in cache is not corrupt from a previous download+extract that might have stopped mid-action
-rw-r--r--src/GlobalLib.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/GlobalLib.cpp b/src/GlobalLib.cpp
index 586ec2d..df66727 100644
--- a/src/GlobalLib.cpp
+++ b/src/GlobalLib.cpp
@@ -40,13 +40,30 @@ namespace sibs
}
case FileType::DIRECTORY:
{
- return Result<bool>::Ok(true);
+ break;
}
default:
{
return Result<bool>::Err("Unexpected error!");
}
}
+
+ // We also need to verify that the archive was removed after extracting it, otherwise the extracted
+ // package could be corrupted. The archive is only removed after extracting is done.
+ // TODO: Find a way to verify that the git repo was cloned fully without interruption, or add .finished files
+ // for every download
+
+ Result<FileString> libPathResult = getHomeDir();
+ if (!libPathResult)
+ return Result<bool>::Err(libPathResult);
+
+ FileString libArchivedFilePath = libPathResult.unwrap();
+ libArchivedFilePath += TINYDIR_STRING("/.cache/sibs/archive/");
+ libArchivedFilePath += toFileString(name);
+ if(getFileType(libArchivedFilePath.c_str()) != FileType::FILE_NOT_FOUND)
+ return Result<bool>::Err("A previous download of package is corrupt, attempting to redownload...");
+
+ return Result<bool>::Ok(true);
}
Result<bool> GlobalLib::getLibs(const std::vector<PackageListDependency*> &libs, const SibsConfig &parentConfig, const FileString &globalLibRootDir, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallbackFunc, GlobalIncludeDirCallbackFunc globalIncludeDirCallback)