From 3edc7d50718c25cd339c84a5726bd401d993c457 Mon Sep 17 00:00:00 2001 From: Kaipeng Deng Date: Thu, 19 Nov 2020 18:57:02 +0800 Subject: [PATCH] fix remove weights on re-download (#1721) --- 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