mirror of https://github.com/kiwix/libkiwix.git
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.
This commit is contained in:
parent
03ab2f67dd
commit
c0b9e2a466
|
@ -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]
|
||||
|
||||
|
|
|
@ -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");
|
||||
<script src="/ROOT/skin/isotope.pkgd.min.js?cacheid=2e48d392" defer></script>
|
||||
<script src="/ROOT/skin/iso6391To3.js?cacheid=ecde2bb3"></script>
|
||||
<script type="text/javascript" src="/ROOT/skin/index.js?cacheid=f2c89cb2" defer></script>
|
||||
<script type="text/javascript" src="/ROOT/skin/index.js?cacheid=0951f06f" defer></script>
|
||||
)EXPECTEDRESULT"
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue