1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-23 00:07:38 +00:00

Merge pull request #20 from Ernest0x/empty_segment_fix

Consider segment incomplete if segment file is empty or too small
This commit is contained in:
Jonas Borgström 2013-12-31 04:59:59 -08:00
commit 57dfe372f6

View file

@ -1,5 +1,6 @@
from configparser import RawConfigParser
from binascii import hexlify
import errno
import os
import re
import shutil
@ -314,7 +315,13 @@ def cleanup(self):
def is_complete_segment(self, filename):
with open(filename, 'rb') as fd:
fd.seek(-self.header_fmt.size, 2)
try:
fd.seek(-self.header_fmt.size, os.SEEK_END)
except Exception as e:
# return False if segment file is empty or too small
if e.errno == errno.EINVAL:
return False
raise e
return fd.read(self.header_fmt.size) == self.COMMIT
def segment_filename(self, segment):