diff options
-rw-r--r-- | src/GlobalLib.cpp | 19 |
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) |