Skip to content

Commit

Permalink
Reduce hangs on file validation process
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcutme committed Mar 12, 2016
1 parent b0ac986 commit 6ff91cd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Site/SiteStorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,15 @@ def getInnerPath(self, path):
# Verify all files sha512sum using content.json
def verifyFiles(self, quick_check=False, add_optional=False, add_changed=True):
bad_files = []
i = 0

if not self.site.content_manager.contents.get("content.json"): # No content.json, download it first
self.site.needFile("content.json", update=True) # Force update to fix corrupt file
self.site.content_manager.loadContent() # Reload content.json
for content_inner_path, content in self.site.content_manager.contents.items():
i += 1
if i % 100 == 0:
time.sleep(0.0001) # Context switch to avoid gevent hangs
if not os.path.isfile(self.getPath(content_inner_path)): # Missing content.json file
self.log.debug("[MISSING] %s" % content_inner_path)
bad_files.append(content_inner_path)
Expand Down Expand Up @@ -324,6 +328,7 @@ def verifyFiles(self, quick_check=False, add_optional=False, add_changed=True):
(content_inner_path, len(content["files"]), quick_check, bad_files, optional_added, optional_removed)
)

time.sleep(0.0001) # Context switch to avoid gevent hangs
return bad_files

# Check and try to fix site files integrity
Expand Down

0 comments on commit 6ff91cd

Please sign in to comment.