Skip to content

Commit c7205bd

Browse files
committed
handle exists in untar_data
1 parent d216ad1 commit c7205bd

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

fastcore/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.3.23"
1+
__version__ = "1.3.24"

fastcore/xtras.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ def untar_dir(fname, dest, rename=False, overwrite=False):
157157
ls = out.ls()
158158
src = ls[0] if len(ls) == 1 else out
159159
dest = dest/(out if rename else src).name
160-
if overwrite: shutil.rmtree(dest, ignore_errors=True)
160+
if dest.exists():
161+
if overwrite: shutil.rmtree(dest)
162+
else: return dest
161163
shutil.move(str(src), dest)
162164
return dest
163165

nbs/03_xtras.ipynb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@
618618
{
619619
"data": {
620620
"text/plain": [
621-
"['g', 'b', 'c', 'e', 'a', 'h', 'd', 'f']"
621+
"['g', 'a', 'b', 'h', 'd', 'f', 'c', 'e']"
622622
]
623623
},
624624
"execution_count": null,
@@ -1016,7 +1016,9 @@
10161016
" ls = out.ls()\n",
10171017
" src = ls[0] if len(ls) == 1 else out\n",
10181018
" dest = dest/(out if rename else src).name\n",
1019-
" if overwrite: shutil.rmtree(dest, ignore_errors=True)\n",
1019+
" if dest.exists():\n",
1020+
" if overwrite: shutil.rmtree(dest)\n",
1021+
" else: return dest\n",
10201022
" shutil.move(str(src), dest)\n",
10211023
" return dest"
10221024
]

settings.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ author = Jeremy Howard and Sylvain Gugger
77
author_email = [email protected]
88
copyright = fast.ai
99
branch = master
10-
version = 1.3.23
10+
version = 1.3.24
1111
min_python = 3.6
1212
audience = Developers
1313
language = English

0 commit comments

Comments
 (0)