def _decompress_dir(archive_path, target_path, force=False): if os.path.exists(target_path): if force: log.info("deleting previous dir: %s", target_path) rmtree_or_file(target_path) else: raise AppError("Target already exists: %r" % target_path) with atomic_output_file(target_path) as temp_dir: make_all_dirs(temp_dir) ARCHIVER.unarchive(archive_path, temp_dir)
def checked_remove(): # Never backup links (they are probably previous installs). if os.path.islink(target_path): os.unlink(target_path) elif os.path.exists(target_path): if force: if make_backup: move_to_backup(target_path) else: rmtree_or_file(target_path) else: raise AppError("Target already exists: %r" % target_path)