summaryrefslogtreecommitdiff
path: root/pygnulib/GLFileSystem.py
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2022-08-03 14:27:51 +0200
committerBruno Haible <bruno@clisp.org>2022-08-03 14:27:51 +0200
commited7b3d9bb825644533235fcc636134bc8bc368f2 (patch)
treea9b4130b353216ef3f476a066f9ef7603e5605e3 /pygnulib/GLFileSystem.py
parentdbc9a4b304185e2cb0d9f425866f71161c9a1255 (diff)
downloadgnulib-ed7b3d9bb825644533235fcc636134bc8bc368f2.tar.gz
gnulib-tool.py: Avoid errors when writing to a VFAT file system, part 2.
* pygnulib/constants.py (movefile): New function. * pygnulib/*.py: Use it instead of shutil.
Diffstat (limited to 'pygnulib/GLFileSystem.py')
-rw-r--r--pygnulib/GLFileSystem.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/pygnulib/GLFileSystem.py b/pygnulib/GLFileSystem.py
index 5368f3c1b8..1f7a9f2343 100644
--- a/pygnulib/GLFileSystem.py
+++ b/pygnulib/GLFileSystem.py
@@ -43,6 +43,7 @@ __copyright__ = constants.__copyright__
DIRS = constants.DIRS
joinpath = constants.joinpath
copyfile = constants.copyfile
+movefile = constants.movefile
isdir = os.path.isdir
isfile = os.path.isfile
@@ -266,7 +267,7 @@ class GLFileAssistant(object):
lookedup, joinpath(destdir, rewritten))
else: # if any of these conditions is not met
try: # Try to move file
- shutil.move(tmpfile, joinpath(destdir, rewritten))
+ movefile(tmpfile, joinpath(destdir, rewritten))
except Exception as error:
raise GLError(17, original)
else: # if self.config['dryrun']
@@ -308,7 +309,7 @@ class GLFileAssistant(object):
if isfile(backuppath):
os.remove(backuppath)
try: # Try to replace the given file
- shutil.move(basepath, backuppath)
+ movefile(basepath, backuppath)
except Exception as error:
raise GLError(17, original)
if self.filesystem.shouldLink(original, lookedup) == CopyAction.Symlink \
@@ -405,8 +406,8 @@ class GLFileAssistant(object):
if not self.config['dryrun']:
if isfile(backuppath):
os.remove(backuppath)
- shutil.move(basepath, backuppath)
- shutil.move(tmpfile, basepath)
+ movefile(basepath, backuppath)
+ movefile(tmpfile, basepath)
else: # if self.config['dryrun']
os.remove(tmpfile)
else: # if not isfile(basepath)
@@ -414,7 +415,7 @@ class GLFileAssistant(object):
if not self.config['dryrun']:
if isfile(basepath):
os.remove(basepath)
- shutil.move(tmpfile, basepath)
+ movefile(tmpfile, basepath)
else: # if self.config['dryrun']
os.remove(tmpfile)
result = tuple([basename, backupname, result_flag])