aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--global-functions25
1 files changed, 21 insertions, 4 deletions
diff --git a/global-functions b/global-functions
index d55d0a6..f1d9ba2 100644
--- a/global-functions
+++ b/global-functions
@@ -137,6 +137,25 @@
}
}
+# clean file path
+:global CleanFilePath do={
+ :local Path [ :tostr $1 ];
+
+ :global CharacterReplace;
+
+ :while ($Path ~ "//") do={
+ :set $Path [ $CharacterReplace $Path "//" "/" ];
+ }
+ :if ([ :pick $Path 0 ] = "/") do={
+ :set Path [ :pick $Path 1 [ :len $Path ] ];
+ }
+ :if ([ :pick $Path ([ :len $Path ] - 1) ] = "/") do={
+ :set Path [ :pick $Path 0 ([ :len $Path ] - 1) ];
+ }
+
+ :return $Path;
+}
+
# download package from upgrade server
:global DownloadPackage do={
:local PkgName [ :tostr $1 ];
@@ -145,16 +164,14 @@
:local PkgDir [ :tostr $4 ];
:global CertificateAvailable;
+ :global CleanFilePath;
:if ([ :len $PkgName ] = 0) do={ return false; }
:if ([ :len $PkgVer ] = 0) do={ :set PkgVer [ / system package update get installed-version ]; }
:if ([ :len $PkgArch ] = 0) do={ :set PkgArch [ / system resource get architecture-name ]; }
:local PkgFile ($PkgName . "-" . $PkgVer . "-" . $PkgArch . ".npk");
- :local PkgDest $PkgFile;
- :if ($PkgDir != "") do={
- :set PkgDest ($PkgDir . "/" . $PkgFile);
- }
+ :local PkgDest [ $CleanFilePath ($PkgDir . "/" . $PkgFile) ];
$CertificateAvailable "Let's Encrypt Authority X3" "letsencrypt";
:do {