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:
commit
57dfe372f6
1 changed files with 8 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
from configparser import RawConfigParser
|
from configparser import RawConfigParser
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
|
import errno
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
@ -314,7 +315,13 @@ def cleanup(self):
|
||||||
|
|
||||||
def is_complete_segment(self, filename):
|
def is_complete_segment(self, filename):
|
||||||
with open(filename, 'rb') as fd:
|
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
|
return fd.read(self.header_fmt.size) == self.COMMIT
|
||||||
|
|
||||||
def segment_filename(self, segment):
|
def segment_filename(self, segment):
|
||||||
|
|
Loading…
Reference in a new issue