diff options
author | Christian Hesse <mail@eworm.de> | 2023-08-30 09:13:13 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2023-08-30 09:30:25 +0200 |
commit | ce822a0276da8ec50c6f7d58d8f0e04971f45a0b (patch) | |
tree | 5681b887a390c3d920eb9eb776f0f72fe6a394c1 /backup-email.rsc | |
parent | f099c2c9ea0a09e7802246b726f6abbc95c2f8ed (diff) |
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.
Diffstat (limited to 'backup-email.rsc')
-rw-r--r-- | backup-email.rsc | 31 |
1 files changed, 8 insertions, 23 deletions
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!"; -} |