Rev571, Optional file sizes to sidebar, Download all optional files option in sidebar, Optional file number in peer stats, Delete removed or changed optional files, Auto download optional files if autodownloadoptional checked, SiteReload command, Peer use global file server if no site defined, Allow browser cache video files, Allow more keepalive connections, Gevent 1.1 ranged request bugfix, Dont sent optional files details on websocket, Remove files from workermanager tasks if no longer in bad_files, Notify local client about changes on external siteSign
This commit is contained in:
parent
2cf34c132f
commit
3587777ea8
17 changed files with 212 additions and 41 deletions
|
@ -130,6 +130,15 @@ class Site:
|
|||
if res is not True and res is not False: # Need downloading and file is allowed
|
||||
file_threads.append(res) # Append evt
|
||||
|
||||
# Optionals files
|
||||
if self.settings.get("autodownloadoptional"):
|
||||
for file_relative_path in self.content_manager.contents[inner_path].get("files_optional", {}).keys():
|
||||
file_inner_path = content_inner_dir + file_relative_path
|
||||
# Start download and dont wait for finish, return the event
|
||||
res = self.needFile(file_inner_path, blocking=False, update=self.bad_files.get(file_inner_path), peer=peer)
|
||||
if res is not True and res is not False: # Need downloading and file is allowed
|
||||
file_threads.append(res) # Append evt
|
||||
|
||||
# Wait for includes download
|
||||
include_threads = []
|
||||
for file_relative_path in self.content_manager.contents[inner_path].get("includes", {}).keys():
|
||||
|
@ -212,6 +221,7 @@ class Site:
|
|||
|
||||
# Wait for peers
|
||||
if not self.peers:
|
||||
self.announce()
|
||||
for wait in range(10):
|
||||
time.sleep(5+wait)
|
||||
self.log.debug("Waiting for peers...")
|
||||
|
@ -258,10 +268,7 @@ class Site:
|
|||
self.log.debug("Fallback to old-style update")
|
||||
self.redownloadContents()
|
||||
|
||||
if self.settings["own"]:
|
||||
self.storage.verifyFiles(quick_check=True) # Check files (need for optional files)
|
||||
else:
|
||||
self.storage.checkFiles(quick_check=True) # Quick check and mark bad files based on file size
|
||||
self.storage.checkFiles(quick_check=True) # Quick check and mark bad files based on file size
|
||||
|
||||
changed, deleted = self.content_manager.loadContent("content.json")
|
||||
|
||||
|
|
|
@ -250,7 +250,7 @@ class SiteStorage:
|
|||
return inner_path
|
||||
|
||||
# Verify all files sha512sum using content.json
|
||||
def verifyFiles(self, quick_check=False): # Fast = using file size
|
||||
def verifyFiles(self, quick_check=False, add_optional=False, add_changed=True):
|
||||
bad_files = []
|
||||
|
||||
if not self.site.content_manager.contents.get("content.json"): # No content.json, download it first
|
||||
|
@ -277,7 +277,8 @@ class SiteStorage:
|
|||
|
||||
if not ok:
|
||||
self.log.debug("[CHANGED] %s" % file_inner_path)
|
||||
bad_files.append(file_inner_path)
|
||||
if add_changed:
|
||||
bad_files.append(file_inner_path)
|
||||
|
||||
# Optional files
|
||||
optional_added = 0
|
||||
|
@ -288,6 +289,8 @@ class SiteStorage:
|
|||
file_path = self.getPath(file_inner_path)
|
||||
if not os.path.isfile(file_path):
|
||||
self.site.content_manager.hashfield.removeHash(content["files_optional"][file_relative_path]["sha512"])
|
||||
if add_optional:
|
||||
bad_files.append(file_inner_path)
|
||||
continue
|
||||
|
||||
if quick_check:
|
||||
|
@ -301,6 +304,8 @@ class SiteStorage:
|
|||
else:
|
||||
self.site.content_manager.hashfield.removeHash(content["files_optional"][file_relative_path]["sha512"])
|
||||
optional_removed += 1
|
||||
if add_optional:
|
||||
bad_files.append(file_inner_path)
|
||||
self.log.debug("[OPTIONAL CHANGED] %s" % file_inner_path)
|
||||
|
||||
self.log.debug(
|
||||
|
@ -313,10 +318,15 @@ class SiteStorage:
|
|||
# Check and try to fix site files integrity
|
||||
def checkFiles(self, quick_check=True):
|
||||
s = time.time()
|
||||
bad_files = self.verifyFiles(quick_check)
|
||||
bad_files = self.verifyFiles(
|
||||
quick_check,
|
||||
add_optional=self.site.settings.get("autodownloadoptional"),
|
||||
add_changed=not self.site.settings.get("own") # Don't overwrite changed files if site owned
|
||||
)
|
||||
self.site.bad_files = {}
|
||||
if bad_files:
|
||||
for bad_file in bad_files:
|
||||
self.site.bad_files[bad_file] = self.site.bad_files.get("bad_file", 0) + 1
|
||||
self.site.bad_files[bad_file] = 1
|
||||
self.log.debug("Checked files in %.2fs... Quick:%s" % (time.time() - s, quick_check))
|
||||
|
||||
# Delete site's all file
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue