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.
This commit is contained in:
Christian Hesse 2023-08-30 09:17:28 +02:00
parent ce822a0276
commit 49d85c6def

View file

@ -100,16 +100,14 @@ $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 *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");
user=$BackupUploadUser password=$BackupUploadPass src-path=($FilePath . ".conf.txt");
:set ConfigFile ($FileName . ".conf");
} on-error={
$LogPrintExit2 error $0 ("Uploading global-config-overlay failed!") false;
@ -117,13 +115,7 @@ $WaitFullyConnected;
:set Failed 1;
}
/file/remove ($FilePath . ".conf");
} else={
$LogPrintExit2 warning $0 ("Creating config file not possible. Limit is 4kB, configuration has " . \
$Size . " bytes.") false;
:set ConfigFile "failed";
:set Failed 1;
}
/file/remove ($FilePath . ".conf.txt");
}
$SendNotification2 ({ origin=$0; \