def source_generate(abs_hashfile, opt): ''' Generate a hash of the local filesystem, optionally using existing signatures to speed up the process. ''' existing_hl = None if not opt.always_checksum and os.path.exists(abs_hashfile): if not opt.quiet: print("Reading existing hashfile") existing_hl = _read_hashlist(abs_hashfile, opt) hashlist = hashlist_generate(opt.source_dir, opt, existing_hashlist=existing_hl) if hashlist is not None: write_success = sigfile_write(hashlist, abs_hashfile, opt, use_tmp=True) if not write_success: log.error("Failed to write signature file '%s'", os.path.join(opt.source_dir, opt.hash_file)) return False return True else: log.error("Send-side generate failed") return False
def source_generate(abs_hashfile, opt): """ Generate a hash of the local filesystem, optionally using existing signatures to speed up the process. """ existing_hl = None if not opt.always_checksum and os.path.exists(abs_hashfile): if not opt.quiet: print("Reading existing hashfile") existing_hl = _read_hashlist(abs_hashfile, opt) hashlist = hashlist_generate(opt.source_dir, opt, existing_hashlist=existing_hl) if hashlist is not None: write_success = sigfile_write(hashlist, abs_hashfile, opt, use_tmp=True) if not write_success: log.error("Failed to write signature file '%s'", os.path.join(opt.source_dir, opt.hash_file)) return False return True else: log.error("Send-side generate failed") return False
def _fetch_remote_impl(needed, not_needed, dst_hashlist, abs_hashfile, opt): # fetch_needed() does almost all the work. (fetch_added, fetch_err_count) = fetch_needed(needed, opt.source_url, opt) # Don't delete things if we had transfer problems. It's safer. delete_status = True if not opt.no_delete and fetch_err_count == 0: delete_status = delete_not_needed(not_needed, opt.dest_dir, opt) if (fetch_err_count > 0 or not delete_status): log.error("Sync failed") return False if len(fetch_added) > 0: log.debug("Adding %d new entries to destination hashlist", len(fetch_added)) dst_hashlist.extend(fetch_added) if not opt.no_write_hashfile and dst_hashlist is not None: if not sigfile_write(dst_hashlist, abs_hashfile, opt, use_tmp=True, verb='Writing', no_compress=True): log.error("Failed to write signature file '%s'", os.path.join(opt.source_dir, opt.hash_file)) return False if not opt.quiet: if fetch_added: print("Files added:") for fh in fetch_added: print("+ %s" % fh.fpath) if not_needed: if opt.no_delete: print("\nCandidates for removal (--no-delete is active):") else: print("\nObjects removed:") for fh in not_needed: print("- %s" % fh.fpath) if opt.verbose: print("\nRaw %s:" % opt.stats.name()) for k, v in opt.stats.iteritems(): print(" %s = %s" % (k, v)) print('') return True