fix: Handle is_search_module_loaded for redis version < 4.0.0 (#27574) (#27578)

- Return False if error occurs

(cherry picked from commit d6ed6d53e9)

Co-authored-by: Marica <maricadsouza221197@gmail.com>
This commit is contained in:
Frappe PR Bot
2021-09-18 15:25:44 +05:30
committed by GitHub
parent a741fd1cfe
commit 5978286b52

View File

@@ -20,14 +20,16 @@ def get_indexable_web_fields():
return [df.fieldname for df in valid_fields]
def is_search_module_loaded():
cache = frappe.cache()
out = cache.execute_command('MODULE LIST')
try:
cache = frappe.cache()
out = cache.execute_command('MODULE LIST')
parsed_output = " ".join(
(" ".join([s.decode() for s in o if not isinstance(s, int)]) for o in out)
)
return "search" in parsed_output
parsed_output = " ".join(
(" ".join([s.decode() for s in o if not isinstance(s, int)]) for o in out)
)
return "search" in parsed_output
except Exception:
return False
def if_redisearch_loaded(function):
"Decorator to check if Redisearch is loaded."