From c0b9e2a466f21b758b92f79288de6942b6c9abfc Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Wed, 6 Apr 2022 15:13:45 +0400 Subject: [PATCH] Cache-id of resources with account for dependency The cache-id of resources now includes dependency information. This commit illustrates that property with the changed cache-id of skin/index.js which depends on skin/{download,hash,magnet,bittorent}.png. The implementation is not fool-proof - cyclic dependency between resources is not detected and will lead to infinite recursion. --- scripts/kiwix-resources | 3 ++- test/server.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/kiwix-resources b/scripts/kiwix-resources index 98db43f7c..0d7c1f85d 100755 --- a/scripts/kiwix-resources +++ b/scripts/kiwix-resources @@ -33,13 +33,14 @@ def list_resources(resource_file_path): print(resource_path) def compute_resource_revision(resource_path): - with open(os.path.join(BASE_DIR, resource_path), 'rb') as f: + with open(os.path.join(OUT_DIR, resource_path), 'rb') as f: return hashlib.sha1(f.read()).hexdigest()[:8] resource_revisions = {} def get_resource_revision(res): if not res in resource_revisions: + preprocess_resource(res) resource_revisions[res] = compute_resource_revision(res) return resource_revisions[res] diff --git a/test/server.cpp b/test/server.cpp index 22fb87897..cb19a5230 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -319,7 +319,7 @@ R"EXPECTEDRESULT( src="/ROOT/skin/jquery-ui/external/jquery/jquery.js?cache src: url("/ROOT/skin/fonts/Roboto.ttf?cacheid=84d10248") format("truetype"); - + )EXPECTEDRESULT" }, {