Updating check_for_upgrade script to fix issue when the LAST_EPOCH file/value got corrupted. Closes #32
This commit is contained in:
parent
33f424134e
commit
cf967e07f9
|
@ -1,11 +1,22 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
current_epoch=$(($(date +%s) / 60 / 60 / 24))
|
function _current_epoch() {
|
||||||
|
echo $(($(date +%s) / 60 / 60 / 24))
|
||||||
|
}
|
||||||
|
|
||||||
|
function _update_zsh_update() {
|
||||||
|
echo "LAST_EPOCH=$(_current_epoch)" > ~/.zsh-update
|
||||||
|
}
|
||||||
|
|
||||||
if [ -f ~/.zsh-update ]
|
if [ -f ~/.zsh-update ]
|
||||||
then
|
then
|
||||||
. ~/.zsh-update
|
. ~/.zsh-update
|
||||||
epoch_diff=$(($current_epoch - $LAST_EPOCH))
|
|
||||||
|
if [[ -z "$LAST_EPOCH" ]]; then
|
||||||
|
_update_zsh_update && return 0;
|
||||||
|
fi
|
||||||
|
|
||||||
|
epoch_diff=$((${_current_epoch} - $LAST_EPOCH))
|
||||||
if [ $epoch_diff -gt 6 ]
|
if [ $epoch_diff -gt 6 ]
|
||||||
then
|
then
|
||||||
echo "[Oh My Zsh] Would you like to check for updates?"
|
echo "[Oh My Zsh] Would you like to check for updates?"
|
||||||
|
@ -15,14 +26,9 @@ then
|
||||||
then
|
then
|
||||||
/bin/sh $ZSH/tools/upgrade.sh
|
/bin/sh $ZSH/tools/upgrade.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set the last epoch to the current so that we don't ask for another week
|
|
||||||
echo "LAST_EPOCH=${current_epoch}" > ~/.zsh-update
|
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
# TODO: refactor this so remove duplicates
|
|
||||||
# Create the ~/.zsh-update file with the current epoch info
|
|
||||||
echo "LAST_EPOCH=${current_epoch}" > ~/.zsh-update
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# update the zsh file
|
||||||
|
_update_zsh_update
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue