de8299d6c4f50bc40286a05cd7e802b6bffe41f0

Author
Chao Du <duchao0726@gmail.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Fixed Issue #4550: Move ~/.zsh-update file to $ZSH_CACHE_DIR

Diff

 1diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
 2index 72527362f8e5f8ac628550413ffe582e51b5d76b..ca505d1ba5bbbe79a121c3b77bf90d04d16a1154 100644
 3--- a/oh-my-zsh.sh
 4+++ b/oh-my-zsh.sh
 5@@ -1,6 +1,12 @@
 6+# Set ZSH_CACHE_DIR to the path where cache files should be created
 7+# or else we will use the default cache/
 8+if [[ -z "$ZSH_CACHE_DIR" ]]; then
 9+  ZSH_CACHE_DIR="$ZSH/cache"
10+fi
11+
12 # Check for updates on initial load...
13 if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then
14-  env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh
15+  env ZSH=$ZSH ZSH_CACHE_DIR=$ZSH_CACHE_DIR DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh
16 fi
17 
18 # Initializes Oh My Zsh
19@@ -17,12 +23,6 @@ if [[ -z "$ZSH_CUSTOM" ]]; then
20     ZSH_CUSTOM="$ZSH/custom"
21 fi
22 
23-# Set ZSH_CACHE_DIR to the path where cache files should be created
24-# or else we will use the default cache/
25-if [[ -z "$ZSH_CACHE_DIR" ]]; then
26-  ZSH_CACHE_DIR="$ZSH/cache"
27-fi
28-
29 
30 # Load all of the config files in ~/oh-my-zsh that end in .zsh
31 # TIP: Add files you don't want in git to .gitignore
32diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh
33index b42b877506a1b8cd95a05f82f68e627a31607c75..05b31e8d42cf4e50e4e4e6a30833bb7922088664 100644
34--- a/tools/check_for_upgrade.sh
35+++ b/tools/check_for_upgrade.sh
36@@ -7,7 +7,7 @@ function _current_epoch() {
37 }
38 
39 function _update_zsh_update() {
40-  echo "LAST_EPOCH=$(_current_epoch)" >! ~/.zsh-update
41+  echo "LAST_EPOCH=$(_current_epoch)" >! ${ZSH_CACHE_DIR}/.zsh-update
42 }
43 
44 function _upgrade_zsh() {
45@@ -30,11 +30,11 @@ fi
46 whence git >/dev/null || return 0
47 
48 if mkdir "$ZSH/log/update.lock" 2>/dev/null; then
49-  if [ -f ~/.zsh-update ]; then
50-    . ~/.zsh-update
51+  if [ -f ${ZSH_CACHE_DIR}/.zsh-update ]; then
52+    . ${ZSH_CACHE_DIR}/.zsh-update
53 
54     if [[ -z "$LAST_EPOCH" ]]; then
55-      _update_zsh_update && return 0;
56+      _update_zsh_update && return 0
57     fi
58 
59     epoch_diff=$(($(_current_epoch) - $LAST_EPOCH))