[file_utils] unln: sync after copy

This commit is contained in:
Matteo Cypriani 2013-04-08 23:25:50 -04:00
parent 7f6d75cd64
commit d77897fd5c
1 changed files with 5 additions and 0 deletions

View File

@ -129,6 +129,11 @@ for filename in sys.argv[1:]:
verbose("Copying to temporary file", quote(tmpfilename), end="... ")
shutil.copy2(filename, tmpfilename) # cp -p
# Try to sync if we are running Python >= 3.3
if sys.version_info.minor >= 3:
verbose("Syncing", end="... ")
os.sync()
# Rename the temporary file with the original file name
verbose("Moving back {} to {}...".format(
quote(tmpfilename), quote(filename)))