File tree 1 file changed +10
-1
lines changed
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 8
8
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
9
9
''' Common interface for any image format--volume or surface, binary or xml.'''
10
10
11
+ import os
11
12
import warnings
12
13
13
14
from .externals .six import string_types
@@ -347,7 +348,15 @@ def to_filename(self, filename):
347
348
-------
348
349
None
349
350
'''
350
- self .file_map = self .filespec_to_file_map (filename )
351
+ self .file_map = file_map = self .filespec_to_file_map (filename )
352
+ for _ , fh in file_map .items ():
353
+ if not isinstance (fh , FileHolder ):
354
+ continue
355
+ if os .path .exists (fh .filename ):
356
+ # Remove previous file where new file would be saved
357
+ # Necessary e.g. for cases where file is a symlink pointing
358
+ # to some non-writable file (e.g. under git annex control)
359
+ os .unlink (fh .filename )
351
360
self .to_file_map ()
352
361
353
362
def to_filespec (self , filename ):
You can’t perform that action at this time.
0 commit comments