File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 88### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
99''' Common interface for any image format--volume or surface, binary or xml.'''
1010
11+ import os
1112import warnings
1213
1314from .externals .six import string_types
@@ -347,7 +348,15 @@ def to_filename(self, filename):
347348 -------
348349 None
349350 '''
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 )
351360 self .to_file_map ()
352361
353362 def to_filespec (self , filename ):
You can’t perform that action at this time.
0 commit comments