mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-04 12:14:11 +00:00
More precise and correct error reporting in replace_file.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
8462a03ed0
commit
5b3b8463ae
@ -4,7 +4,7 @@ Futz with files like a pro.
|
|||||||
|
|
||||||
import sys, exceptions, os, stat, tempfile, time, binascii
|
import sys, exceptions, os, stat, tempfile, time, binascii
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from errno import EEXIST, ENOENT
|
from errno import ENOENT
|
||||||
|
|
||||||
from twisted.python import log
|
from twisted.python import log
|
||||||
|
|
||||||
@ -618,12 +618,14 @@ else:
|
|||||||
|
|
||||||
if not os.path.exists(replacement_path):
|
if not os.path.exists(replacement_path):
|
||||||
raise ConflictError("Replacement file not found: %r" % (replacement_path,))
|
raise ConflictError("Replacement file not found: %r" % (replacement_path,))
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.rename(replaced_path, backup_path)
|
||||||
|
except OSError as e:
|
||||||
|
print e, e.errno
|
||||||
|
if e.errno != ENOENT:
|
||||||
|
raise
|
||||||
try:
|
try:
|
||||||
try:
|
|
||||||
os.rename(replaced_path, backup_path)
|
|
||||||
except OSError as e:
|
|
||||||
if e.errno != errno.EEXIST:
|
|
||||||
raise
|
|
||||||
rename_no_overwrite(replacement_path, replaced_path)
|
rename_no_overwrite(replacement_path, replaced_path)
|
||||||
except EnvironmentError:
|
except EnvironmentError:
|
||||||
reraise(ConflictError)
|
reraise(ConflictError)
|
||||||
|
Loading…
Reference in New Issue
Block a user