Skip to content

Commit

Permalink
Remove the use of _ prefixfor private functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
herve-er committed May 8, 2024
1 parent e826527 commit 8979641
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
16 changes: 8 additions & 8 deletions src/server/logarchiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,31 @@ ExitCode LogArchiver::generateLogsSupportArchive(bool includeArchivedLogs, const
return ExitCodeSystemError;
}

ExitCode exitCode = _copyLogsTo(tempLogArchiveDir, includeArchivedLogs, exitCause);
ExitCode exitCode = copyLogsTo(tempLogArchiveDir, includeArchivedLogs, exitCause);
if (exitCode != ExitCodeOk) {
LOG_WARN(Log::instance()->getLogger(), "Unable to copy logs to temp folder: " << exitCause);
IoHelper::deleteDirectory(tempLogArchiveDir.parent_path(), ioError);
return exitCode;
}

// Copy .parmsdb to temp folder
exitCode = _copyParmsDbTo(tempLogArchiveDir / ".parms.db", exitCause);
exitCode = copyParmsDbTo(tempLogArchiveDir / ".parms.db", exitCause);
if (exitCode != ExitCodeOk) {
LOG_WARN(Log::instance()->getLogger(), "Unable to copy .parms.db to temp folder: " << exitCause);
IoHelper::deleteDirectory(tempLogArchiveDir.parent_path(), ioError);
return exitCode;
}

// Generate user description file
exitCode = _generateUserDescriptionFile(tempLogArchiveDir, exitCause);
exitCode = generateUserDescriptionFile(tempLogArchiveDir, exitCause);
if (exitCode != ExitCodeOk) {
LOG_WARN(Log::instance()->getLogger(), "Unable to generate user description file: " << exitCause);
IoHelper::deleteDirectory(tempLogArchiveDir.parent_path(), ioError);
return exitCode;
}

// compress all the files in the folder
exitCode = _compressLogFiles(tempLogArchiveDir, exitCause, progressCallback);
exitCode = compressLogFiles(tempLogArchiveDir, exitCause, progressCallback);
if (exitCode != ExitCodeOk) {
LOG_WARN(Log::instance()->getLogger(), "Unable to compress logs: " << exitCause);
IoHelper::deleteDirectory(tempLogArchiveDir.parent_path(), ioError);
Expand Down Expand Up @@ -199,7 +199,7 @@ ExitCode LogArchiver::generateLogsSupportArchive(bool includeArchivedLogs, const
return ExitCodeOk;
}

ExitCode LogArchiver::_copyLogsTo(const SyncPath& outputPath, bool includeArchivedLogs, ExitCause& exitCause) {
ExitCode LogArchiver::copyLogsTo(const SyncPath& outputPath, bool includeArchivedLogs, ExitCause& exitCause) {
exitCause = ExitCauseUnknown;
SyncPath logPath = Log::instance()->getLogFilePath().parent_path();

Expand Down Expand Up @@ -243,7 +243,7 @@ ExitCode LogArchiver::_copyLogsTo(const SyncPath& outputPath, bool includeArchiv
return ExitCodeOk;
}

ExitCode LogArchiver::_copyParmsDbTo(const SyncPath& outputPath, ExitCause& exitCause) {
ExitCode LogArchiver::copyParmsDbTo(const SyncPath& outputPath, ExitCause& exitCause) {
const SyncPath parmsDbName = ".parms.db";
const SyncPath parmsDbPath = CommonUtility::getAppSupportDir() / parmsDbName;
DirectoryEntry entryParmsDb;
Expand Down Expand Up @@ -273,7 +273,7 @@ ExitCode LogArchiver::_copyParmsDbTo(const SyncPath& outputPath, ExitCause& exit
return ExitCodeOk;
}

ExitCode LogArchiver::_compressLogFiles(const SyncPath& directoryToCompress, ExitCause& exitCause,
ExitCode LogArchiver::compressLogFiles(const SyncPath& directoryToCompress, ExitCause& exitCause,
std::function<void(int)> progressCallback) {
IoHelper::DirectoryIterator dir;
IoError ioError = IoErrorUnknown;
Expand Down Expand Up @@ -350,7 +350,7 @@ ExitCode LogArchiver::_compressLogFiles(const SyncPath& directoryToCompress, Exi
return ExitCodeOk;
}

ExitCode LogArchiver::_generateUserDescriptionFile(const SyncPath& outputPath, ExitCause& exitCause) {
ExitCode LogArchiver::generateUserDescriptionFile(const SyncPath& outputPath, ExitCause& exitCause) {
exitCause = ExitCauseUnknown;

std::string osName = CommonUtility::platformName().toStdString();
Expand Down
8 changes: 4 additions & 4 deletions src/server/logarchiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class LogArchiver {

private:
friend class TestLogArchiver;
static ExitCode _copyLogsTo(const SyncPath &outputPath, bool includeArchivedLogs, ExitCause &exitCause);
static ExitCode _copyParmsDbTo(const SyncPath &outputPath, ExitCause &exitCause);
static ExitCode copyLogsTo(const SyncPath &outputPath, bool includeArchivedLogs, ExitCause &exitCause);
static ExitCode copyParmsDbTo(const SyncPath &outputPath, ExitCause &exitCause);

/*! Compresses the log files in the given directory.
* This method will not create an archive, it will only compress the files in the directory.
Expand All @@ -54,7 +54,7 @@ class LogArchiver {
* \param progressCallback The callback to be called with the progress percentage.
* \return The exit code of the operation.
*/
static ExitCode _compressLogFiles(const SyncPath &directoryToCompress, ExitCause &exitCause,
static ExitCode compressLogFiles(const SyncPath &directoryToCompress, ExitCause &exitCause,
std::function<void(int)> progressCallback = nullptr);

/*! Generates a file containing the user description.
Expand All @@ -63,7 +63,7 @@ class LogArchiver {
* \param exitCause The exit cause to be filled in case of error. If no error occurred, it will be set to ExitCauseUnknown;
* \return The exit code of the operation.
*/
static ExitCode _generateUserDescriptionFile(const SyncPath &outputPath, ExitCause &exitCause);
static ExitCode generateUserDescriptionFile(const SyncPath &outputPath, ExitCause &exitCause);
};

} // namespace KDC
20 changes: 10 additions & 10 deletions test/server/logarchiver/testlogarchiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void TestLogArchiver::testCopyLogsTo(void) {
CPPUNIT_ASSERT(logDirsize >= 0);

ExitCause cause = ExitCauseUnknown;
ExitCode exitCode = LogArchiver::_copyLogsTo(tempDir.path, true, cause);
ExitCode exitCode = LogArchiver::copyLogsTo(tempDir.path, true, cause);
CPPUNIT_ASSERT_EQUAL(ExitCauseUnknown, cause);
CPPUNIT_ASSERT_EQUAL(ExitCodeOk, exitCode);

Expand All @@ -107,7 +107,7 @@ void TestLogArchiver::testCopyLogsTo(void) {

// compress the log file
ExitCause cause = ExitCauseUnknown;
ExitCode exitCode = LogArchiver::_compressLogFiles(tempDir.path, cause);
ExitCode exitCode = LogArchiver::compressLogFiles(tempDir.path, cause);
CPPUNIT_ASSERT_EQUAL(ExitCauseUnknown, cause);
CPPUNIT_ASSERT_EQUAL(ExitCodeOk, exitCode);

Expand All @@ -118,7 +118,7 @@ void TestLogArchiver::testCopyLogsTo(void) {

IoHelper::deleteDirectory(tempDir.path / "test.log.gz", err);

exitCode = LogArchiver::_copyLogsTo(tempDir.path, false, cause);
exitCode = LogArchiver::copyLogsTo(tempDir.path, false, cause);
IoHelper::deleteDirectory(logDir / "test.log.gz", err);

CPPUNIT_ASSERT_EQUAL(ExitCauseUnknown, cause);
Expand All @@ -134,7 +134,7 @@ void TestLogArchiver::testCopyLogsTo(void) {

void TestLogArchiver::testCopyParmsDbTo(void) {
{
if (!_parmsDbFileExist()) {
if (!parmsDbFileExist()) {
std::cout << std::endl << "No .parms.db file, this test will not be relevant (skipped)." << std::endl;
LOG_WARN(_logger, "No .parms.db file, this test will not be relevant (skipped).");
return;
Expand All @@ -153,7 +153,7 @@ void TestLogArchiver::testCopyParmsDbTo(void) {
CPPUNIT_ASSERT(parmsDbSize >= 0);

ExitCause cause = ExitCauseUnknown;
ExitCode exitCode = LogArchiver::_copyParmsDbTo(tempDir.path, cause);
ExitCode exitCode = LogArchiver::copyParmsDbTo(tempDir.path, cause);
CPPUNIT_ASSERT_EQUAL(ExitCauseUnknown, cause);
CPPUNIT_ASSERT_EQUAL(ExitCodeOk, exitCode);

Expand Down Expand Up @@ -192,7 +192,7 @@ void TestLogArchiver::testCompressLogs(void) {
CPPUNIT_ASSERT(logDirSize >= 0);

ExitCause cause = ExitCauseUnknown;
const ExitCode exitCode = LogArchiver::_compressLogFiles(tempDir.path, cause);
const ExitCode exitCode = LogArchiver::compressLogFiles(tempDir.path, cause);

CPPUNIT_ASSERT_EQUAL(ExitCauseUnknown, cause);
CPPUNIT_ASSERT_EQUAL(ExitCodeOk, exitCode);
Expand Down Expand Up @@ -231,7 +231,7 @@ void TestLogArchiver::testCompressLogs(void) {
};

ExitCause cause = ExitCauseUnknown;
const ExitCode exitCode = LogArchiver::_compressLogFiles(tempDir.path, cause, progress);
const ExitCode exitCode = LogArchiver::compressLogFiles(tempDir.path, cause, progress);

CPPUNIT_ASSERT_EQUAL(ExitCauseUnknown, cause);
CPPUNIT_ASSERT_EQUAL(ExitCodeOk, exitCode);
Expand All @@ -244,7 +244,7 @@ void TestLogArchiver::testGenerateUserDescriptionFile(void) {
TemporaryDirectory tempDir;
const SyncPath userDescriptionFile = tempDir.path / "user_description.txt";
ExitCause cause = ExitCauseUnknown;
ExitCode code = LogArchiver::_generateUserDescriptionFile(userDescriptionFile, cause);
ExitCode code = LogArchiver::generateUserDescriptionFile(userDescriptionFile, cause);
CPPUNIT_ASSERT_EQUAL(ExitCauseUnknown, cause);
CPPUNIT_ASSERT_EQUAL(ExitCodeOk, code);

Expand All @@ -267,7 +267,7 @@ void TestLogArchiver::testGenerateUserDescriptionFile(void) {
}

void TestLogArchiver::testGenerateLogsSupportArchive(void) {
if (!_parmsDbFileExist()) {
if (!parmsDbFileExist()) {
std::cout << std::endl << "No .parms.db file, this test will not be relevant (skipped)." << std::endl;
LOG_WARN(_logger, "No .parms.db file, this test will not be relevant (skipped).");
return;
Expand All @@ -290,7 +290,7 @@ void TestLogArchiver::testGenerateLogsSupportArchive(void) {
}
}

bool TestLogArchiver::_parmsDbFileExist() {
bool TestLogArchiver::parmsDbFileExist() {
const SyncPath parmsDbName = ".parms.db";
const SyncPath parmsDbPath = CommonUtility::getAppSupportDir() / parmsDbName;

Expand Down
2 changes: 1 addition & 1 deletion test/server/logarchiver/testlogarchiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class TestLogArchiver : public CppUnit::TestFixture {
void testGenerateLogsSupportArchive(void);

private:
bool _parmsDbFileExist();
bool parmsDbFileExist();
};

} // namespace KDC

0 comments on commit 8979641

Please sign in to comment.