This commit is contained in:
Melvin Lammerts 2017-05-16 00:31:56 +00:00 committed by GitHub
commit 4417e7b7e6

View file

@ -10,10 +10,19 @@ function _update_zsh_update() {
echo "LAST_EPOCH=$(_current_epoch)" >! ~/.zsh-update echo "LAST_EPOCH=$(_current_epoch)" >! ~/.zsh-update
} }
function _create_lock() {
touch ~/.zsh-update.lock
}
function _remove_lock() {
rm ~/.zsh-update.lock
}
function _upgrade_zsh() { function _upgrade_zsh() {
_create_lock
env ZSH=$ZSH sh $ZSH/tools/upgrade.sh env ZSH=$ZSH sh $ZSH/tools/upgrade.sh
# update the zsh file # update the zsh file
_update_zsh_update _update_zsh_update
_remove_lock
} }
epoch_target=$UPDATE_ZSH_DAYS epoch_target=$UPDATE_ZSH_DAYS
@ -22,6 +31,9 @@ if [[ -z "$epoch_target" ]]; then
epoch_target=13 epoch_target=13
fi fi
# Cancel upgrade if upgrade is already in progress
[[ ! -f ~/.zsh-update.lock ]] || return 0
# Cancel upgrade if the current user doesn't have write permissions for the # Cancel upgrade if the current user doesn't have write permissions for the
# oh-my-zsh directory. # oh-my-zsh directory.
[[ -w "$ZSH" ]] || return 0 [[ -w "$ZSH" ]] || return 0