repository: check_free_space, special case small repos

This commit is contained in:
Marian Beermann 2016-11-12 14:42:11 +01:00
parent 80b86709ef
commit 00fae3f3e3
No known key found for this signature in database
GPG Key ID: 9B8450B91D1362C1
1 changed files with 12 additions and 2 deletions

View File

@ -428,8 +428,18 @@ class Repository:
required_free_space += self.additional_free_space required_free_space += self.additional_free_space
if not self.append_only: if not self.append_only:
# Keep one full worst-case segment free in non-append-only mode full_segment_size = self.max_segment_size + MAX_OBJECT_SIZE
required_free_space += self.max_segment_size + MAX_OBJECT_SIZE if len(self.compact) < 10:
# This is mostly for the test suite to avoid overestimated free space needs. This can be annoying
# if TMP is a small-ish tmpfs.
compact_working_space = sum(self.io.segment_size(segment) - free for segment, free in self.compact.items())
logger.debug('check_free_space: few segments, not requiring a full free segment')
compact_working_space = min(compact_working_space, full_segment_size)
logger.debug('check_free_space: calculated working space for compact as %d bytes', compact_working_space)
required_free_space += compact_working_space
else:
# Keep one full worst-case segment free in non-append-only mode
required_free_space += full_segment_size
try: try:
st_vfs = os.statvfs(self.path) st_vfs = os.statvfs(self.path)
except OSError as os_error: except OSError as os_error: