Use shutil.move rather than os.rename
When the source and destination file paths are not on the same partition os.rename raises OSError: [Errno 18] Invalid cross-device link. Use shutil.move instead. Change-Id: I28d6cb6c15a4496243fab7ec6c7eedcd1422f4c2 Closes-Bug: #1833804
This commit is contained in:
parent
89be711592
commit
fb1b4bec0f
|
@ -19,6 +19,7 @@ import subprocess
|
|||
import glob
|
||||
import tempfile
|
||||
import time
|
||||
import shutil
|
||||
import socket
|
||||
|
||||
from collections import OrderedDict
|
||||
|
@ -737,7 +738,7 @@ def update_hosts_file(map):
|
|||
for line in lines:
|
||||
hosts.write(line)
|
||||
|
||||
os.rename(tmpfile.name, HOSTS_FILE)
|
||||
shutil.move(tmpfile.name, HOSTS_FILE)
|
||||
os.chmod(HOSTS_FILE, 0o644)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue