Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH 23/25] Improve `___luarocks_installed_rocks_cache_policy`.



From: Doron Behar <doron.behar@xxxxxxxxx>

Handle multiple trees when evaluating installed rocks cache validity -
both system wide and user's.
---
 Completion/Unix/Command/_luarocks | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/Completion/Unix/Command/_luarocks b/Completion/Unix/Command/_luarocks
index cb42d1b36..8de95c188 100644
--- a/Completion/Unix/Command/_luarocks
+++ b/Completion/Unix/Command/_luarocks
@@ -87,14 +87,14 @@ __luarocks_lua_versions(){
 # {{{ helper: installed rocks cache policy
 (( $+functions[___luarocks_installed_rocks_cache_policy] )) ||
 ___luarocks_installed_rocks_cache_policy(){
-  # TODO enable the user to configure manifests file that will be checked here with zstyle
-  # the number of seconds since 1970-01-01 the manifest file was modified
-  local manifest_last_date_modified="$(date -r ~/.luarocks/lib/luarocks/rocks-5.3/manifest +%s 2>/dev/null)"
+  # the number of seconds since 1970-01-01 the manifest files were modified
+  local user_manifest_last_date_modified="$(date -r ${HOME}/.luarocks/lib/luarocks/rocks-5.3/manifest +%s 2>/dev/null)"
+  local system_manifest_last_date_modified="$(date -r /usr/lib/luarocks/rocks-5.3/manifest +%s 2>/dev/null)"
   # the number of seconds since 1970-01-01 the cache file was modified
   local cache_last_date_modified="$(date -r $1 +%s 2>/dev/null)"
-  if [[ ! -z ${cache_last_date_modified} && ! -z ${manifest_last_date_modified} ]]; then
+  if [[ ! -z ${cache_last_date_modified} && ! -z ${user_manifest_last_date_modified} && ! -z ${system_manifest_last_date_modified} ]]; then
     # if the manifest file is newer then the cache:
-    if [ ${manifest_last_date_modified} -ge ${cache_last_date_modified} ]; then
+    if [ ${user_manifest_last_date_modified} -ge ${cache_last_date_modified} ] || [ ${system_manifest_last_date_modified} -ge ${cache_last_date_modified} ]; then
       (( 1 ))
     else
       (( 0 ))
-- 
2.17.0



Messages sorted by: Reverse Date, Date, Thread, Author