summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--searx/plugins/__init__.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/searx/plugins/__init__.py b/searx/plugins/__init__.py
index 66ff93c2a..8742dc2d6 100644
--- a/searx/plugins/__init__.py
+++ b/searx/plugins/__init__.py
@@ -15,6 +15,7 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >.
(C) 2015 by Adam Tauber, <asciimoo@gmail.com>
'''
+from hashlib import sha256
from importlib import import_module
from os.path import abspath, basename, dirname, exists, join
from shutil import copyfile
@@ -109,7 +110,7 @@ def check_resource(base_path, resource_path, name, dir_prefix):
file_name = basename(dep_path)
resource_name = '{0}_{1}'.format('_'.join(name.split()), file_name)
resource_path = join(static_path, 'plugins', dir_prefix, resource_name)
- if not exists(resource_path):
+ if not exists(resource_path) or sha_sum(dep_path) != sha_sum(resource_path):
try:
copyfile(dep_path, resource_path)
except:
@@ -133,6 +134,12 @@ def fix_package_resources(pkg, name):
])
+def sha_sum(filename):
+ with open(filename,"rb") as f:
+ bytes = f.read() # read entire file as bytes
+ return sha256(bytes).hexdigest()
+
+
plugins = PluginStore()
plugins.register(oa_doi_rewrite)
plugins.register(https_rewrite)