diff options
author | Adam Tauber <asciimoo@gmail.com> | 2020-07-28 13:57:57 +0200 |
---|---|---|
committer | Adam Tauber <asciimoo@gmail.com> | 2020-07-28 13:57:57 +0200 |
commit | 93ac4db312f0ec04bc631714a8fbc2054fe7578b (patch) | |
tree | f8a0ee99aa4d11e7e0617448d4b35db337de37a4 /searx/plugins/__init__.py | |
parent | 164e4725f3ab4adcc0c1527d0ae01965109cfd0d (diff) | |
download | searxng-93ac4db312f0ec04bc631714a8fbc2054fe7578b.tar.gz searxng-93ac4db312f0ec04bc631714a8fbc2054fe7578b.zip |
[enh] copy atime_ns and mtime_ns of external plugin resources
Diffstat (limited to 'searx/plugins/__init__.py')
-rw-r--r-- | searx/plugins/__init__.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/searx/plugins/__init__.py b/searx/plugins/__init__.py index 457183a1e..c701df640 100644 --- a/searx/plugins/__init__.py +++ b/searx/plugins/__init__.py @@ -17,7 +17,7 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >. from hashlib import sha256 from importlib import import_module -from os import listdir, makedirs, remove +from os import listdir, makedirs, remove, stat, utime from os.path import abspath, basename, dirname, exists, join from shutil import copyfile from sys import version_info @@ -113,6 +113,10 @@ def sync_resource(base_path, resource_path, name, target_dir, plugin_dir): if not exists(resource_path) or sha_sum(dep_path) != sha_sum(resource_path): try: copyfile(dep_path, resource_path) + # copy atime_ns and mtime_ns, so the weak ETags (generated by + # the HTTP server) do not change + dep_stat = stat(dep_path) + utime(resource_path, ns=(dep_stat.st_atime_ns, dep_stat.st_mtime_ns)) except: logger.critical('failed to copy plugin resource {0} for plugin {1}'.format(file_name, name)) exit(3) |