Skip to content

Commit 2a4d622

Browse files
authored
Merge pull request iterative#2173 from efiop/master
dvc: use remove() instead of shutil.rmtree()
2 parents 5b01804 + 9bca1c9 commit 2a4d622

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

dvc/external_repo.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from dvc.cache import CacheConfig
1313
from dvc.exceptions import DvcException
1414
from dvc.utils.compat import makedirs, str
15+
from dvc.utils import remove
1516

1617

1718
logger = logging.getLogger(__name__)
@@ -120,7 +121,7 @@ def install(self, cache_dir=None, force=False):
120121
self._install_to(tmp_dir, cache_dir)
121122
except ExternalRepoError:
122123
if os.path.exists(tmp_dir):
123-
shutil.rmtree(tmp_dir)
124+
remove(tmp_dir)
124125
raise
125126

126127
if self.installed:
@@ -137,7 +138,7 @@ def uninstall(self):
137138
)
138139
return
139140

140-
shutil.rmtree(self.path)
141+
remove(self.path)
141142

142143
def update(self):
143144
self.repo.scm.fetch(self.rev)

dvc/repo/destroy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import shutil
1+
from dvc.utils import remove
22

33

44
def destroy(self):
55
for stage in self.stages():
66
stage.remove(remove_outs=False)
77

8-
shutil.rmtree(self.dvc_dir)
8+
remove(self.dvc_dir)

dvc/repo/get.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import os
2-
import shutil
32
import shortuuid
43

54
from dvc.config import Config
65
from dvc.path_info import PathInfo
76
from dvc.external_repo import ExternalRepo
87
from dvc.utils.compat import urlparse
8+
from dvc.utils import remove
99

1010

1111
@staticmethod
@@ -45,4 +45,4 @@ def get(url, path, out=None, rev=None):
4545
erepo.repo.scm.git.close()
4646
finally:
4747
if os.path.exists(tmp_dir):
48-
shutil.rmtree(tmp_dir)
48+
remove(tmp_dir)

dvc/repo/init.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import os
2-
import shutil
32
import colorama
43
import logging
54

65
from dvc.repo import Repo
76
from dvc.scm import SCM, NoSCM
87
from dvc.config import Config
98
from dvc.exceptions import InitError
10-
from dvc.utils import boxify
11-
from dvc.utils import relpath
9+
from dvc.utils import boxify, relpath, remove
1210

1311
logger = logging.getLogger(__name__)
1412

@@ -78,7 +76,7 @@ def init(root_dir=os.curdir, no_scm=False, force=False):
7876
)
7977
)
8078

81-
shutil.rmtree(dvc_dir)
79+
remove(dvc_dir)
8280

8381
os.mkdir(dvc_dir)
8482

0 commit comments

Comments
 (0)