diff options
| author | Adam Tauber <asciimoo@gmail.com> | 2020-07-14 21:51:38 +0200 |
|---|---|---|
| committer | Adam Tauber <asciimoo@gmail.com> | 2020-07-28 13:10:40 +0200 |
| commit | 7b93d11d841aee8da7825d7608ac1308944d88d9 (patch) | |
| tree | 97d4f616e38f49de43c3f2c284ea6e9460500163 | |
| parent | 1f2dc6c64785ab962efbeed0cfc093fdd3f41bf0 (diff) | |
[fix] add plugin sha sum check to be able to copy updated resources
| -rw-r--r-- | searx/plugins/__init__.py | 9 |
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) |