Renames tmp file to final destination Returns true if commit succeeded
| 66 | // Renames tmp file to final destination |
| 67 | // Returns true if commit succeeded |
| 68 | bool ProcessSessionReadCallback::commit() { |
| 69 | bool success = false; |
| 70 | |
| 71 | logger_->log_debug("committing export operation to %s", _destFile); |
| 72 | |
| 73 | if (_writeSucceeded) { |
| 74 | if (!_tmpFileOs.flush()) { |
| 75 | return false; |
| 76 | } |
| 77 | _tmpFileOs.close(); |
| 78 | |
| 79 | if (rename(_tmpFile.c_str(), _destFile.c_str())) { |
| 80 | logger_->log_warn("commit export operation to %s failed because rename() call failed", _destFile); |
| 81 | } else { |
| 82 | success = true; |
| 83 | logger_->log_debug("commit export operation to %s succeeded", _destFile); |
| 84 | } |
| 85 | } else { |
| 86 | logger_->log_error("commit export operation to %s failed because write failed", _destFile); |
| 87 | } |
| 88 | return success; |
| 89 | } |
| 90 | |
| 91 | // Clean up resources |
| 92 | ProcessSessionReadCallback::~ProcessSessionReadCallback() { |