aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-08-30 09:17:28 +0200
committerGravatar Christian Hesse <mail@eworm.de>2023-08-30 09:30:25 +0200
commit49d85c6def6426a64b2ae516af80609cd17af317 (patch)
treed1b36f86a57cbfe7ff0e026187c34733496d3b16
parentce822a0276da8ec50c6f7d58d8f0e04971f45a0b (diff)
backup-upload: revert changes, add comment with warning
Turned out that using `/file/add ...` introduced a regression. Accessing (reading and writing) file contents is limited to 4095 bytes. This limitation does not exist for `:execute script=... file=...`, so keep the old code. Also add a comment with warning.
-rw-r--r--backup-upload.rsc34
1 files changed, 13 insertions, 21 deletions
diff --git a/backup-upload.rsc b/backup-upload.rsc
index ec76385..7d4b1d1 100644
--- a/backup-upload.rsc
+++ b/backup-upload.rsc
@@ -100,30 +100,22 @@ $WaitFullyConnected;
# global-config-overlay
:if ($BackupSendGlobalConfig = true) do={
- :local Config [ /system/script/get global-config-overlay source ];
- :local Size [ :len $Config ];
-
- :if ($Size <= 4095) {
- /file/add name=($FilePath . ".conf") contents=$Config;
- $WaitForFile ($FilePath . ".conf");
-
- :do {
- /tool/fetch upload=yes url=($BackupUploadUrl . "/" . $FileName . ".conf") \
- user=$BackupUploadUser password=$BackupUploadPass src-path=($FilePath . ".conf");
- :set ConfigFile ($FileName . ".conf");
- } on-error={
- $LogPrintExit2 error $0 ("Uploading global-config-overlay failed!") false;
- :set ConfigFile "failed";
- :set Failed 1;
- }
-
- /file/remove ($FilePath . ".conf");
- } else={
- $LogPrintExit2 warning $0 ("Creating config file not possible. Limit is 4kB, configuration has " . \
- $Size . " bytes.") false;
+ # Do *NOT* use '/file/add ...' here, as it is limited to 4095 bytes!
+ :execute script={ :put [ /system/script/get global-config-overlay source ]; } \
+ file=($FilePath . ".conf");
+ $WaitForFile ($FilePath . ".conf.txt");
+
+ :do {
+ /tool/fetch upload=yes url=($BackupUploadUrl . "/" . $FileName . ".conf") \
+ user=$BackupUploadUser password=$BackupUploadPass src-path=($FilePath . ".conf.txt");
+ :set ConfigFile ($FileName . ".conf");
+ } on-error={
+ $LogPrintExit2 error $0 ("Uploading global-config-overlay failed!") false;
:set ConfigFile "failed";
:set Failed 1;
}
+
+ /file/remove ($FilePath . ".conf.txt");
}
$SendNotification2 ({ origin=$0; \