Skip to content

Commit 97aff7d

Browse files
veloman-yunkanmgautierfr
authored andcommitted
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.
1 parent c7e1792 commit 97aff7d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

scripts/kiwix-resources

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ def list_resources(resource_file_path):
3333
print(resource_path)
3434

3535
def compute_resource_revision(resource_path):
36-
with open(os.path.join(BASE_DIR, resource_path), 'rb') as f:
36+
with open(os.path.join(OUT_DIR, resource_path), 'rb') as f:
3737
return hashlib.sha1(f.read()).hexdigest()[:8]
3838

3939
resource_revisions = {}
4040

4141
def get_resource_revision(res):
4242
if not res in resource_revisions:
43+
preprocess_resource(res)
4344
resource_revisions[res] = compute_resource_revision(res)
4445
return resource_revisions[res]
4546

test/server.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ R"EXPECTEDRESULT( src="/ROOT/skin/jquery-ui/external/jquery/jquery.js?cache
318318
src: url("/ROOT/skin/fonts/Roboto.ttf?cacheid=84d10248") format("truetype");
319319
<script src="/ROOT/skin/isotope.pkgd.min.js?cacheid=2e48d392" defer></script>
320320
<script src="/ROOT/skin/iso6391To3.js?cacheid=ecde2bb3"></script>
321-
<script type="text/javascript" src="/ROOT/skin/index.js?cacheid=f2c89cb2" defer></script>
321+
<script type="text/javascript" src="/ROOT/skin/index.js?cacheid=0951f06f" defer></script>
322322
)EXPECTEDRESULT"
323323
},
324324
{

0 commit comments

Comments
 (0)