Skip to content

Commit

Permalink
Boost js, css, dbschema and non-user json file priority
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcutme committed Mar 12, 2017
1 parent f46f9fa commit d7496d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/Test/TestSiteDownload.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ def testDownload(self, file_server, site, site_temp):
def boostRequest(inner_path):
# I really want these file
if inner_path == "index.html":
site_temp.needFile("data/img/multiuser.png", priority=9, blocking=False)
site_temp.needFile("data/img/direct_domains.png", priority=10, blocking=False)
site_temp.needFile("data/img/multiuser.png", priority=5, blocking=False)
site_temp.needFile("data/img/direct_domains.png", priority=5, blocking=False)
site_temp.onFileDone.append(boostRequest)
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")]
# Test priority
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[4:6] == ["css/all.css", "js/all.js"] # Important assets
assert file_requests[6] == "dbschema.json" # Database map
assert file_requests[2:4] == ["css/all.css", "js/all.js"] # Important assets
assert file_requests[4] == "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

# Check files
Expand Down
11 changes: 7 additions & 4 deletions src/Worker/WorkerManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,18 @@ def getPriorityBoost(self, inner_path):
if "-default" in inner_path:
return -4 # Default files are cloning not important
elif inner_path.endswith(".css"):
return 5 # boost css files priority
return 7 # boost css files priority
elif inner_path.endswith(".js"):
return 4 # boost js files priority
return 6 # boost js files priority
elif inner_path.endswith("dbschema.json"):
return 3 # boost database specification
return 5 # boost database specification
elif inner_path.endswith("content.json"):
return 1 # boost included content.json files priority a bit
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

# Create new task and return asyncresult
Expand Down

0 comments on commit d7496d6

Please sign in to comment.