From 3f3ce129f0a0d8ea99e46e9cfed31dc157df232b Mon Sep 17 00:00:00 2001 From: Kaipeng Deng Date: Thu, 19 Nov 2020 22:06:52 +0800 Subject: [PATCH] fix remove weights on re-download (#1722) --- ppdet/utils/download.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ppdet/utils/download.py b/ppdet/utils/download.py index 58f7be307..6e4cb4019 100644 --- a/ppdet/utils/download.py +++ b/ppdet/utils/download.py @@ -213,7 +213,10 @@ def get_path(url, root_dir, md5sum=None, check_exist=True): logger.debug("Found {}".format(fullpath)) return fullpath, True else: - shutil.rmtree(fullpath) + if osp.isdir(fullpath): + shutil.rmtree(fullpath) + else: + os.remove(fullpath) fullname = _download(url, root_dir, md5sum) -- GitLab