[PATCH 3/3] dim: check for updates daily, not at random
Jani Nikula
jani.nikula at intel.com
Wed Oct 11 16:49:55 UTC 2017
Use a timestamp file to check for updates every 24 hours.
Signed-off-by: Jani Nikula <jani.nikula at intel.com>
---
dim | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/dim b/dim
index 578e76cbc273..527989aff9ad 100755
--- a/dim
+++ b/dim
@@ -378,6 +378,20 @@ function dim_uptodate
fi
}
+function check_for_updates
+{
+ local stamp stampfile
+
+ stampfile=$HOME/.dim-update-check-timestamp
+
+ # daily check for updates based on file timestamp
+ stamp=$(stat --printf=%Y $stampfile 2>/dev/null || echo -n 0)
+ if [[ $((stamp + 24*60*60)) -lt $(date +%s) ]]; then
+ dim_uptodate || true
+ touch $stampfile
+ fi
+}
+
function git_fetch_helper # remote
{
local remote
@@ -2103,9 +2117,7 @@ function dim_usage
}
# occasional check for dim updates
-if [[ "$(($(date +%s) % 100))" -eq "0" ]] ; then
- dim_uptodate || true
-fi
+check_for_updates
# dim subcommand aliases (with bash 4.3+)
if ! declare -n subcmd=dim_alias_${subcommand//-/_} &> /dev/null || \
--
2.11.0
More information about the dim-tools
mailing list