mirror of https://github.com/searx/searx
[enh] copy atime_ns and mtime_ns of external plugin resources
This commit is contained in:
parent
164e4725f3
commit
93ac4db312
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue