From bb1cd58e9ab74e929d13569e62e701f5a82b844b Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Sun, 1 Nov 2009 02:05:11 +0100 Subject: [PATCH] Introduce support for min_{gc,mirror}_interval --- Girocco/Config.pm | 6 ++++++ daemons/gc.sh | 4 ++++ daemons/update.sh | 4 ++++ shlib.sh | 11 +++++++++++ 4 files changed, 25 insertions(+) diff --git a/Girocco/Config.pm b/Girocco/Config.pm index e831789..c1a64c5 100644 --- a/Girocco/Config.pm +++ b/Girocco/Config.pm @@ -48,6 +48,12 @@ our $project_owners = 'email'; # 'README': our @project_fields = qw(homepage shortdesc README); +# Minimal number of seconds to pass between two updates of a project. +our $min_mirror_interval = 3600; # 1 hour + +# Minimal number of seconds to pass between two garbage collections of a project. +our $min_gc_interval = 604800; # 1 week + ## Paths diff --git a/daemons/gc.sh b/daemons/gc.sh index d8ce17d..1366131 100755 --- a/daemons/gc.sh +++ b/daemons/gc.sh @@ -7,6 +7,10 @@ set -e proj="$1" cd "$cfg_reporoot/$proj.git" +if check_interval lastgc $cfg_min_gc_intreval; then + progress "= [$proj] garbage check skip (last at $(config_get lastgc))" + exit 0 +fi progress "+ [$proj] garbage check (`date`)" # safe pruning: we put all our objects to all forks, then we can diff --git a/daemons/update.sh b/daemons/update.sh index 346d78e..69ed9f3 100755 --- a/daemons/update.sh +++ b/daemons/update.sh @@ -7,6 +7,10 @@ set -e proj="$1" cd "$cfg_reporoot/$proj.git" +if check_interval lastrefresh $cfg_min_mirror_intreval; then + progress "= [$proj] update skip (last at $(config_get lastrefresh))" + exit 0 +fi progress "+ [$proj] update (`date`)" bang_setup diff --git a/shlib.sh b/shlib.sh index 7215bac..2f3dc84 100644 --- a/shlib.sh +++ b/shlib.sh @@ -73,6 +73,17 @@ config_set() { } +# Tool for checking whether at least given number of seconds passed +check_interval() { + od="$(config_get "$1")" + [ -n "$od" ] || return 1 + os="$(date +%s -d "$od")" + [ -n "$os" ] || return 1 + ns="$(date +%s)" + [ $ns -gt $(($os+$2)) ] +} + + # List all Git repositories, with given prefix if specified, one-per-line get_repo_list() { if [ -n "$1" ]; then -- 2.11.4.GIT