Adds support for sliding check
This commit is contained in:
parent
6f0eeea38f
commit
fd8039e275
31
bin/update
31
bin/update
|
@ -46,11 +46,15 @@ _check_date_if_format() {
|
|||
|
||||
_date_format() {
|
||||
|
||||
case $UPDATE_CHECK in
|
||||
"daily") echo +%d/%m/%Y;;
|
||||
"weekly") echo +%V/%Y;;
|
||||
"monthly") echo +%m/%Y;;
|
||||
esac
|
||||
if [ "$UPDATE_CHECK_TYPE" = "sliding" ]; then
|
||||
echo "+%s"
|
||||
else
|
||||
case $UPDATE_CHECK in
|
||||
"daily") echo +%d/%m/%Y;;
|
||||
"weekly") echo +%V/%Y;;
|
||||
"monthly") echo +%m/%Y;;
|
||||
esac
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
@ -95,12 +99,27 @@ _check_date() {
|
|||
|
||||
local old_date=`cat ~/.config/dotfiles/.data/update_date`
|
||||
local new_date=`date $1`
|
||||
local updated=0
|
||||
|
||||
if [ "$new_date" != "$old_date" ] && [ ! -f ~/.config/dotfiles/.data/update_lock ]; then
|
||||
if [ "$UPDATE_CHECK_TYPE" = "sliding" ]; then
|
||||
local diff=$(($new_date - $old_date))
|
||||
case $UPDATE_CHECK in
|
||||
"daily") [ $diff -lt 86400 ] && updated=1;;
|
||||
"weekly") [ $diff -lt 604800 ] && updated=1;;
|
||||
"monthly") [$diff -lt 18748800 ] && updated=1;;
|
||||
esac
|
||||
else
|
||||
if [ "$new_date" = "$old_date" ] ; then
|
||||
updated=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $updated -eq 0 ] && [ ! -f ~/.config/dotfiles/.data/update_lock ]; then
|
||||
_sentence not_updated
|
||||
elif [ "$UPDATE_CHECK_ALWAYS" = "true" ] || [ "$2" = "force" ]; then
|
||||
_sentence updated
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# Returns 0 if $1 > $2
|
||||
|
|
Loading…
Reference in New Issue