From ce822a0276da8ec50c6f7d58d8f0e04971f45a0b Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 30 Aug 2023 09:13:13 +0200 Subject: backup-email: 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. --- backup-email.rsc | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) (limited to 'backup-email.rsc') diff --git a/backup-email.rsc b/backup-email.rsc index 3beb730..e4cd504 100644 --- a/backup-email.rsc +++ b/backup-email.rsc @@ -23,7 +23,6 @@ :global CharacterReplace; :global DeviceInfo; :global FormatLine; -:global IfThenElse; :global LogPrintExit2; :global MkDir; :global RandomDelay; @@ -58,7 +57,6 @@ $WaitFullyConnected; :local ExportFile "none"; :local ConfigFile "none"; :local Attach ({}); -:local Failed 0; :if ([ $MkDir $DirName ] = false) do={ $LogPrintExit2 error $0 ("Failed creating directory!") true; @@ -82,27 +80,18 @@ $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"); - :set ConfigFile ($FileName . ".conf"); - :set Attach ($Attach, ($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; - } + # 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"); + :set ConfigFile ($FileName . ".conf.txt"); + :set Attach ($Attach, ($FilePath . ".conf.txt")); } # send email with status and files $SendEMail2 ({ origin=$0; \ - subject=[ $IfThenElse ($Failed > 0) \ - ([ $SymbolForNotification "floppy-disk,warning-sign" ] . "Backup & Config with failure") \ - ([ $SymbolForNotification "floppy-disk,incoming-envelope" ] . "Backup & Config") ]; \ + subject=([ $SymbolForNotification "floppy-disk,incoming-envelope" ] . \ + "Backup & Config"); \ message=("See attached files for backup and config export for " . \ $Identity . ".\n\n" . \ [ $DeviceInfo ] . "\n\n" . \ @@ -120,7 +109,3 @@ $SendEMail2 ({ origin=$0; \ :delay 1s; :set I ($I + 1); } - -:if ($Failed = 1) do={ - :error "An error occured!"; -} -- cgit v1.2.3-54-g00ecf