def clean_if_necessary()

in scripts/clean-large-folder.py [0:0]


def clean_if_necessary(folder, threshold_size):
    root_dir = Path(folder)
    size = sum(f.stat().st_size for f in root_dir.glob(
        '**/*') if f.is_file())

    print(f"The size of {folder} is {size}, threshold is {threshold_size}")
    if size > threshold_size:
        print(f"Folder size exceeds the threshold, remove it")
        shutil.rmtree(folder)