From a68d463041bfa90ae8de330daa224b7b170da837 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 10 Oct 2017 00:51:13 +0200 Subject: [PATCH] don't crash in first part of truncate_and_unlink, fixes #3117 (cherry picked from commit 7a689b1295ca647a7f9008df508f303214930d08) --- src/borg/helpers.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/borg/helpers.py b/src/borg/helpers.py index 0e71ad5b5..f1721c52b 100644 --- a/src/borg/helpers.py +++ b/src/borg/helpers.py @@ -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)