Skip to content

Commit 3f48cb7

Browse files
authored
Merge pull request #1570 from effigies/readlink_bug
FIX: Fix symlink test in copyfile
2 parents 5b29a5c + 4fdfa44 commit 3f48cb7

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Upcoming release 0.13
33

44
* TST: reduce the size of docker images & use tags for images (https://github.com/nipy/nipype/pull/1564)
55
* ENH: Implement missing inputs/outputs in FSL AvScale (https://github.com/nipy/nipype/pull/1563)
6+
* FIX: Fix symlink test in copyfile (https://github.com/nipy/nipype/pull/1570)
67

78

89
Release 0.12.1 (August 3, 2016)

nipype/utils/filemanip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ def copyfile(originalfile, newfile, copy=False, create_new=False,
234234
keep = False
235235
if os.path.lexists(newfile):
236236
if os.path.islink(newfile):
237-
if all(os.path.readlink(newfile) == originalfile, not use_hardlink,
238-
not copy):
237+
if all((os.readlink(newfile) == originalfile, not use_hardlink,
238+
not copy)):
239239
keep = True
240240
elif posixpath.samefile(newfile, originalfile):
241241
keep = True

nipype/utils/tests/test_filemanip.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,21 @@ def test_linkchain():
157157
yield assert_false, os.path.islink(new_hdr3)
158158
yield assert_true, os.path.samefile(orig_img, new_img3)
159159
yield assert_true, os.path.samefile(orig_hdr, new_hdr3)
160+
161+
# Test that re-copying leaves files
162+
stat1 = os.stat(new_img1)
163+
stat2 = os.stat(new_img2)
164+
stat3 = os.stat(new_img3)
165+
# Same symlink
166+
copyfile(orig_img, new_img1)
167+
# Hash matches
168+
copyfile(new_img1, new_img2, copy=True)
169+
# Hardlinks
170+
copyfile(new_img1, new_img3, copy=True, use_hardlink=True)
171+
yield assert_equal, stat1, os.stat(new_img1)
172+
yield assert_equal, stat2, os.stat(new_img2)
173+
yield assert_equal, stat3, os.stat(new_img3)
174+
160175
os.unlink(new_img1)
161176
os.unlink(new_hdr1)
162177
os.unlink(new_img2)

0 commit comments

Comments
 (0)