Boost js, css, dbschema and non-user json file priority
This commit is contained in:
parent
f46f9fa6ea
commit
d7496d6fd5
2 changed files with 12 additions and 9 deletions
|
@ -35,16 +35,16 @@ class TestSiteDownload:
|
||||||
def boostRequest(inner_path):
|
def boostRequest(inner_path):
|
||||||
# I really want these file
|
# I really want these file
|
||||||
if inner_path == "index.html":
|
if inner_path == "index.html":
|
||||||
site_temp.needFile("data/img/multiuser.png", priority=9, blocking=False)
|
site_temp.needFile("data/img/multiuser.png", priority=5, blocking=False)
|
||||||
site_temp.needFile("data/img/direct_domains.png", priority=10, blocking=False)
|
site_temp.needFile("data/img/direct_domains.png", priority=5, blocking=False)
|
||||||
site_temp.onFileDone.append(boostRequest)
|
site_temp.onFileDone.append(boostRequest)
|
||||||
site_temp.download(blind_includes=True).join(timeout=5)
|
site_temp.download(blind_includes=True).join(timeout=5)
|
||||||
file_requests = [request[2]["inner_path"] for request in requests if request[0] in ("getFile", "streamFile")]
|
file_requests = [request[2]["inner_path"] for request in requests if request[0] in ("getFile", "streamFile")]
|
||||||
# Test priority
|
# Test priority
|
||||||
assert file_requests[0:2] == ["content.json", "index.html"] # Must-have files
|
assert file_requests[0:2] == ["content.json", "index.html"] # Must-have files
|
||||||
assert file_requests[2:4] == ["data/img/direct_domains.png", "data/img/multiuser.png"] # Directly requested files
|
assert file_requests[2:4] == ["css/all.css", "js/all.js"] # Important assets
|
||||||
assert file_requests[4:6] == ["css/all.css", "js/all.js"] # Important assets
|
assert file_requests[4] == "dbschema.json" # Database map
|
||||||
assert file_requests[6] == "dbschema.json" # Database map
|
assert file_requests[5:7] == ["data/img/multiuser.png", "data/img/direct_domains.png"] # Directly requested files
|
||||||
assert "-default" in file_requests[-1] # Put default files for cloning to the end
|
assert "-default" in file_requests[-1] # Put default files for cloning to the end
|
||||||
|
|
||||||
# Check files
|
# Check files
|
||||||
|
|
|
@ -384,15 +384,18 @@ class WorkerManager(object):
|
||||||
if "-default" in inner_path:
|
if "-default" in inner_path:
|
||||||
return -4 # Default files are cloning not important
|
return -4 # Default files are cloning not important
|
||||||
elif inner_path.endswith(".css"):
|
elif inner_path.endswith(".css"):
|
||||||
return 5 # boost css files priority
|
return 7 # boost css files priority
|
||||||
elif inner_path.endswith(".js"):
|
elif inner_path.endswith(".js"):
|
||||||
return 4 # boost js files priority
|
return 6 # boost js files priority
|
||||||
elif inner_path.endswith("dbschema.json"):
|
elif inner_path.endswith("dbschema.json"):
|
||||||
return 3 # boost database specification
|
return 5 # boost database specification
|
||||||
elif inner_path.endswith("content.json"):
|
elif inner_path.endswith("content.json"):
|
||||||
return 1 # boost included content.json files priority a bit
|
return 1 # boost included content.json files priority a bit
|
||||||
elif inner_path.endswith(".json"):
|
elif inner_path.endswith(".json"):
|
||||||
return 2 # boost data json files priority more
|
if len(inner_path) < 50: # Boost non-user json files more
|
||||||
|
return 4
|
||||||
|
else:
|
||||||
|
return 2
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
# Create new task and return asyncresult
|
# Create new task and return asyncresult
|
||||||
|
|
Loading…
Reference in a new issue