aboutsummaryrefslogtreecommitdiff
path: root/status
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2024-08-04 00:18:15 -0300
committerSilvio Rhatto <rhatto@riseup.net>2024-08-04 00:18:15 -0300
commitcb94262779f42533e8fc7cf670484a699543ea52 (patch)
treeef4eef2a5443665ed3b3dbd2efd10fc9108efc12 /status
parent7a2e43e9da275f9ccddcb68cb1be203a8d19091c (diff)
downloadscripts-cb94262779f42533e8fc7cf670484a699543ea52.tar.gz
scripts-cb94262779f42533e8fc7cf670484a699543ea52.tar.bz2
Fix: status: add status_file_changed_delta function
Diffstat (limited to 'status')
-rwxr-xr-xstatus18
1 files changed, 15 insertions, 3 deletions
diff --git a/status b/status
index 948cba6..b357b4e 100755
--- a/status
+++ b/status
@@ -58,6 +58,20 @@ function status_options {
fi
}
+# Calculate timestamp delta from a file
+function status_file_changed_delta {
+ local file="$1"
+
+ if [ -z "$file" ] || [ ! -e "$file" ]; then
+ echo 0
+ fi
+
+ local file_timestamp="`stat -c '%Z' $file`"
+ local timestamp="`date +%s`"
+
+ echo $(( timestamp - file_timestamp ))
+}
+
# Run status
function status_run {
if [ ! -z "$PROJECT" ]; then
@@ -84,9 +98,7 @@ function status_run {
if [ ! -e "$mrconfig" ]; then
mrconfig_run="1"
else
- local mrconfig_timestamp="`stat -c '%Z' $mrconfig`"
- local timestamp="`date +%s`"
- local mrconfig_age="$(( timestamp - mrconfig_timestamp ))"
+ local mrconfig_age="`status_file_changed_delta $mrconfig`"
local mrconfig_interval="3600"
# Run mrconfig-updater only every hour or so