From: Brendan Hansen Date: Thu, 19 May 2022 03:22:14 +0000 (-0500) Subject: bugfix in onyx-pkg where errors leave stray folder X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=90c843c9c85b97033f782f14fea0131fd996f572;p=onyx.git bugfix in onyx-pkg where errors leave stray folder --- diff --git a/scripts/onyx-pkg.onyx b/scripts/onyx-pkg.onyx index 841504cc..3df59bd0 100644 --- a/scripts/onyx-pkg.onyx +++ b/scripts/onyx-pkg.onyx @@ -1,7 +1,7 @@ #load "core/std" -Version :: SemVer.{0, 1, 0} +Version :: SemVer.{0, 1, 1} use package core use package core.intrinsics.onyx {__initialize, __zero_value} @@ -528,10 +528,14 @@ Git :: struct { actual_dest := tprintf("{}/{}", config.config.lib_source_directory, install_dest); if os.dir_exists(actual_dest) { eprintf("Expected {} to not exist when fetching {}.\n", actual_dest, repo); + os.remove_directory(full_dest); return false; } - if !os.dir_rename(full_dest, actual_dest) do return false; + if !os.dir_rename(full_dest, actual_dest) { + os.remove_directory(full_dest); + return false; + } // Remove the .git folder, as it is unneeded. unnecessary_git_dir := tprintf("{}/.git", actual_dest);