Skip to content

Commit

Permalink
Merge pull request #344 from UMEP-dev/matthewp/issue332
Browse files Browse the repository at this point in the history
Added alternative to os.rename for some file systems that return os e…
  • Loading branch information
sunt05 authored Jan 29, 2025
2 parents 63f2dcf + b1f9681 commit ee52fed
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/supy/util/_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from pathlib import Path
from shutil import copyfile, move, rmtree
from tempfile import TemporaryDirectory
import shutil

import f90nml
import numpy as np
Expand Down Expand Up @@ -474,7 +475,15 @@ def convert_utf8(file_src):
e.write(text)

os.remove(path_src) # remove old encoding file
path_dst.rename(path_src)
try:
path_dst.rename(path_src)
except OSError as e:
if e.errno == 18:
logger_supy.error("Invalid cross-link device")
shutil.copy2(path_dst, path_src)
os.remove(path_dst)
else:
raise e

# os.rename(trgfile, srcfile) # rename new encoding
except UnicodeDecodeError:
Expand Down

0 comments on commit ee52fed

Please sign in to comment.