mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-26 17:57:59 +00:00
Merge pull request #3118 from ThomasWaldmann/fallback-no-truncate
don't crash in first part of truncate_and_unlink, fixes #3117
This commit is contained in:
commit
17cfc2c4a4
1 changed files with 8 additions and 2 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import errno
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import re
|
import re
|
||||||
|
@ -141,8 +142,13 @@ def truncate_and_unlink(path):
|
||||||
recover. Refer to the "File system interaction" section
|
recover. Refer to the "File system interaction" section
|
||||||
in repository.py for further explanations.
|
in repository.py for further explanations.
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
with open(path, 'r+b') as fd:
|
with open(path, 'r+b') as fd:
|
||||||
fd.truncate()
|
fd.truncate()
|
||||||
|
except OSError as err:
|
||||||
|
if err.errno != errno.ENOTSUP:
|
||||||
|
raise
|
||||||
|
# don't crash if the above ops are not supported.
|
||||||
os.unlink(path)
|
os.unlink(path)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue