MCPcopy Index your code
hub / github.com/HelloZeroNet/ZeroNet / isReadable

Method isReadable

plugins/Bigfile/BigfilePlugin.py:620–631  ·  view source on GitHub ↗
(self, site, inner_path, file, pos)

Source from the content-addressed store, hash-verified

618@PluginManager.registerTo("FileRequest")
619class FileRequestPlugin(object):
620 def isReadable(self, site, inner_path, file, pos):
621 # Peek into file
622 if file.read(10) == b"\0" * 10:
623 # Looks empty, but makes sures we don't have that piece
624 file_info = site.content_manager.getFileInfo(inner_path)
625 if "piece_size" in file_info:
626 piece_i = int(pos / file_info["piece_size"])
627 if not site.storage.piecefields[file_info["sha512"]][piece_i]:
628 return False
629 # Seek back to position we want to read
630 file.seek(pos)
631 return super(FileRequestPlugin, self).isReadable(site, inner_path, file, pos)
632
633 def actionGetPiecefields(self, params):
634 site = self.sites.get(params["site"])

Callers

nothing calls this directly

Calls 3

readMethod · 0.45
getFileInfoMethod · 0.45
seekMethod · 0.45

Tested by

no test coverage detected