global-functions: $DownloadPackage: make directory first

The fetch command creates the directory itself, however using $MkDir
gives better error message when creating directory fails.
This commit is contained in:
Christian Hesse 2021-12-14 00:00:23 +01:00
parent 5846b85e28
commit 229a7d18c9

View file

@ -251,6 +251,7 @@
:global CertificateAvailable;
:global CleanFilePath;
:global LogPrintExit2;
:global MkDir;
:global WaitForFile;
:if ([ :len $PkgName ] = 0) do={ :return false; }
@ -263,6 +264,11 @@
}
:local PkgDest [ $CleanFilePath ($PkgDir . "/" . $PkgFile) ];
:if ([ $MkDir $PkgDir ] = false) do={
$LogPrintExit2 warning $0 ("Failed creating directory, not downloading package.") false;
:return false;
}
:if ([ :len [ / file find where name=$PkgDest type="package" ] ] > 0) do={
$LogPrintExit2 info $0 ("Package file " . $PkgName . " already exists.") false;
:return true;