20
20
import numpy as np
21
21
22
22
from .misc import is_container
23
- from .config import mkdir_p
24
23
from ..external .six import string_types
25
24
from ..interfaces .traits_extension import isdefined
26
25
@@ -246,10 +245,10 @@ def copyfile(originalfile, newfile, copy=False, create_new=False,
246
245
elif hashmethod == 'content' :
247
246
hashfn = hash_infile
248
247
newhash = hashfn (newfile )
249
- fmlogger .debug ("File: %s already exists,%s, copy:%d"
250
- % (newfile , newhash , copy ))
248
+ fmlogger .debug ("File: %s already exists,%s, copy:%d" %
249
+ (newfile , newhash , copy ))
251
250
orighash = hashfn (originalfile )
252
- keep = hashfn ( newfile ) == hashfn ( originalfile )
251
+ keep = newhash == orighash
253
252
if keep :
254
253
fmlogger .debug ("File: %s already exists, not overwriting, copy:%d"
255
254
% (newfile , copy ))
@@ -267,7 +266,7 @@ def copyfile(originalfile, newfile, copy=False, create_new=False,
267
266
# Use realpath to avoid hardlinking symlinks
268
267
os .link (os .path .realpath (originalfile ), newfile )
269
268
except OSError :
270
- use_hardlink = False # Disable for associated files
269
+ use_hardlink = False # Disable hardlink for associated files
271
270
else :
272
271
keep = True
273
272
@@ -276,7 +275,7 @@ def copyfile(originalfile, newfile, copy=False, create_new=False,
276
275
fmlogger .debug ("Symlinking File: %s->%s" % (newfile , originalfile ))
277
276
os .symlink (originalfile , newfile )
278
277
except OSError :
279
- copy = True # Disable for associated files
278
+ copy = True # Disable symlink for associated files
280
279
else :
281
280
keep = True
282
281
@@ -294,12 +293,15 @@ def copyfile(originalfile, newfile, copy=False, create_new=False,
294
293
matofile = originalfile [:- 4 ] + ".mat"
295
294
if os .path .exists (matofile ):
296
295
matnfile = newfile [:- 4 ] + ".mat"
297
- copyfile (matofile , matnfile , copy , use_hardlink = use_hardlink )
298
- copyfile (hdrofile , hdrnfile , copy , use_hardlink = use_hardlink )
296
+ copyfile (matofile , matnfile , copy , hashmethod = hashmethod ,
297
+ use_hardlink = use_hardlink )
298
+ copyfile (hdrofile , hdrnfile , copy , hashmethod = hashmethod ,
299
+ use_hardlink = use_hardlink )
299
300
elif originalfile .endswith (".BRIK" ):
300
301
hdrofile = originalfile [:- 5 ] + ".HEAD"
301
302
hdrnfile = newfile [:- 5 ] + ".HEAD"
302
- copyfile (hdrofile , hdrnfile , copy , use_hardlink = use_hardlink )
303
+ copyfile (hdrofile , hdrnfile , copy , hashmethod = hashmethod ,
304
+ use_hardlink = use_hardlink )
303
305
304
306
return newfile
305
307
0 commit comments