mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-01 04:37:34 +00:00
Merge pull request #3129 from ThomasWaldmann/fallback-no-truncate-1.1
don't crash in first part of truncate_and_unlink, fixes #3117
This commit is contained in:
commit
8ca6dc03d2
1 changed files with 8 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
|||
import contextlib
|
||||
import collections
|
||||
import enum
|
||||
import errno
|
||||
import grp
|
||||
import hashlib
|
||||
import logging
|
||||
|
@ -2283,8 +2284,13 @@ def truncate_and_unlink(path):
|
|||
recover. Refer to the "File system interaction" section
|
||||
in repository.py for further explanations.
|
||||
"""
|
||||
with open(path, 'r+b') as fd:
|
||||
fd.truncate()
|
||||
try:
|
||||
with open(path, 'r+b') as fd:
|
||||
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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue