Skip to content

Commit 1ec803b

Browse files
authored
Merge pull request #210 from timvaillancourt/issue_193_no_compress
Check if Backup/Mongodump.py 'auto' compress mode can actually support compression (#193)
2 parents 4e6d46b + a1630db commit 1ec803b

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

mongodb_consistent_backup/Backup/Mongodump/Mongodump.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@ def parse_mongodump_version(self):
5656
raise OperationError("Could not parse mongodump --version output!")
5757

5858
def choose_compression(self):
59-
if self.can_gzip():
59+
if self.can_compress():
6060
if self.compression() == 'auto':
6161
logging.info("Mongodump binary supports gzip compression, auto-enabling gzip compression")
6262
self.compression('gzip')
6363
elif self.compression() == 'gzip':
6464
raise OperationError("mongodump gzip compression requested on binary that does not support gzip!")
6565

66-
def can_gzip(self):
66+
def can_compress(self):
6767
if os.path.isfile(self.binary) and os.access(self.binary, os.X_OK):
68-
logging.debug("Mongodump binary supports gzip")
68+
logging.debug("Mongodump binary supports gzip compression")
6969
if tuple("3.2.0".split(".")) <= tuple(self.version.split(".")):
7070
return True
7171
return False

mongodb_consistent_backup/Pipeline/Stage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def close(self):
6464
def is_compressed(self):
6565
if self.has_task() and hasattr(self._task, "is_compressed"):
6666
return self._task.is_compressed()
67+
return False
6768

6869
def compression(self, task=None):
6970
if self.has_task() and hasattr(self._task, "compression"):

mongodb_consistent_backup/Pipeline/Task.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ def compression(self, method=None):
3939
return parse_method(self.compression_method)
4040

4141
def is_compressed(self):
42-
if self.compression() != 'none':
42+
if self.compression() == 'auto' and hasattr(self, "can_compress"):
43+
return self.can_compress()
44+
elif self.compression() != 'none':
4345
return True
4446
return False
4547

0 commit comments

Comments
 (0)