mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-22 15:57:15 +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:
commit
57dfe372f6
1 changed files with 8 additions and 1 deletions
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue