Пример #1
0
    if not create_parent_dirs(path):
        return
    full_path = os.path.join(root_dir, path)
    print(f"Creating dir {full_path}")
    if not args.dry_run:
        try:
            fh = os.open(full_path, os.O_RDONLY)
        except PermissionError:
            print("Error opening directory", file=sys.stderr)
            return
        client.mkdir(path, fh)
        os.close(fh)
    created_dirs[path] = True


file_finder.process(root_dir, process_local_file, process_local_dir)


def delete_files(el, current_path=""):
    if el.children is not None:
        for chld in el.children.values():
            delete_files(chld, os.path.join(current_path, chld.name))
    if current_path not in local_files and current_path not in local_dirs and current_path != '':
        print(f"Deleting {current_path}")
        if not args.dry_run:
            client.delete(current_path)


delete_files(server_files.root)

print("Done")