From 93ac4db312f0ec04bc631714a8fbc2054fe7578b Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Tue, 28 Jul 2020 13:57:57 +0200 Subject: [PATCH] [enh] copy atime_ns and mtime_ns of external plugin resources --- searx/plugins/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/searx/plugins/__init__.py b/searx/plugins/__init__.py index 457183a1..c701df64 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)