Example #1
0
def remove_directory(dir_path):
    try:
        # Since no all storages support exists for directories, we check for OSError
        contents = IMAGE_CACHE_STORAGE.listdir(dir_path)
    except OSError:
        pass
    else:
        for directory in contents[0]:
            safe_delete(os.path.join(dir_path, directory))
        for filename in contents[1]:
            safe_delete(os.path.join(dir_path, filename))

    if IMAGE_CACHE_STORAGE.exists(dir_path):
        # In some storages like amazon S3 there are no directories
        safe_delete(dir_path)
Example #2
0
def remove_directory(dir_path):
    try:
        # Since no all storages support exists for directories, we check for OSError
        contents = IMAGE_CACHE_STORAGE.listdir(dir_path)
    except OSError:
        pass
    else:
        for directory in contents[0]:
            safe_delete(os.path.join(dir_path, directory))
        for filename in contents[1]:
            safe_delete(os.path.join(dir_path, filename))

    if IMAGE_CACHE_STORAGE.exists(dir_path):
        # In some storages like amazon S3 there are no directories
        safe_delete(dir_path)