Beispiel #1
0
def describe_share(abs_sharefile, si_s, shnum_s, now, out):
    with open(abs_sharefile, "rb") as f:
        prefix = f.read(32)
        if MutableShareFile.is_valid_header(prefix):
            _describe_mutable_share(abs_sharefile, f, now, si_s, out)
        elif ShareFile.is_valid_header(prefix):
            _describe_immutable_share(abs_sharefile, now, si_s, out)
        else:
            print("UNKNOWN really-unknown %s" % quote_output(abs_sharefile),
                  file=out)
Beispiel #2
0
 def _iter_share_files(self, storage_index):
     for shnum, filename in self.get_shares(storage_index):
         with open(filename, 'rb') as f:
             header = f.read(32)
         if MutableShareFile.is_valid_header(header):
             sf = MutableShareFile(filename, self)
             # note: if the share has been migrated, the renew_lease()
             # call will throw an exception, with information to help the
             # client update the lease.
         elif ShareFile.is_valid_header(header):
             sf = ShareFile(filename)
         else:
             continue  # non-sharefile
         yield sf