luci-app-ddns: fix update time calculation
authorsmall_5 <61473216+small-5@users.noreply.github.com>
Thu, 4 Mar 2021 02:50:25 +0000 (10:50 +0800)
committerJo-Philipp Wich <jo@mein.io>
Tue, 3 May 2022 13:53:25 +0000 (15:53 +0200)
* Fix last_update overflow

* Fix next_update wrong when the router is just started

* Fix missing check_seconds for next_update

Signed-off-by: Small_5 <61473216+small-5@users.noreply.github.com>
(cherry picked from commit 58ed2b211a1add5fb2cb3750af6074c4d51c307a)

applications/luci-app-ddns/root/usr/libexec/rpcd/luci.ddns

index 36c6bdf269ddb245544200d1769f77b324f6c18a..22abcf4251328319ac494c9f0446e1d977e6713d 100755 (executable)
@@ -109,15 +109,15 @@ local methods = {
                                        tonumber(s["force_interval"]) or 72,
                                        s["force_unit"] or "hours" )
 
-                               -- process running but update needs to happen
-                               -- problems if force_seconds > uptime
-                               force_seconds = (force_seconds > uptime) and uptime or force_seconds
+                               local check_seconds = calc_seconds(
+                                       tonumber(s["check_interval"]) or 10,
+                                       s["check_unit"] or "minutes" )
 
                                if last_update > 0 then
-                                       local epoch = os.time() - uptime + last_update + force_seconds
+                                       local epoch = os.time() - uptime + last_update
                                        -- use linux date to convert epoch
                                        converted_last_update = epoch2date(epoch,date_format)
-                                       next_update = epoch2date(epoch + force_seconds)
+                                       next_update = epoch2date(epoch + force_seconds + check_seconds)
                                end
 
                                if pid > 0 and ( last_update + force_seconds - uptime ) <= 0 then