MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / archiveExecute

Method archiveExecute

src/jrd/replication/ChangeLog.cpp:676–773  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

674}
675
676bool ChangeLog::archiveExecute(Segment* segment)
677{
678 if (m_config->archiveCommand.hasData())
679 {
680 segment->truncate();
681
682 auto archiveCommand = m_config->archiveCommand;
683
684 const auto filename = segment->getFileName();
685 const auto pathname = m_config->journalDirectory + filename;
686
687 const auto archpathname = m_config->archiveDirectory.hasData() ?
688 m_config->archiveDirectory + filename : "";
689
690 size_t pos;
691
692 while ( (pos = archiveCommand.find(FILENAME_WILDCARD)) != string::npos)
693 archiveCommand.replace(pos, strlen(FILENAME_WILDCARD), filename);
694
695 while ( (pos = archiveCommand.find(PATHNAME_WILDCARD)) != string::npos)
696 archiveCommand.replace(pos, strlen(PATHNAME_WILDCARD), pathname);
697
698 while ( (pos = archiveCommand.find(ARCHPATHNAME_WILDCARD)) != string::npos)
699 archiveCommand.replace(pos, strlen(ARCHPATHNAME_WILDCARD), archpathname);
700
701 LockCheckout checkout(this);
702
703 fb_assert(archiveCommand.hasData());
704 const auto res = executeShell(archiveCommand);
705
706 if (res)
707 {
708 string errorMsg;
709
710 if (res < 0)
711 {
712 errorMsg.printf("Cannot execute journal archive command (error %d): %s",
713 ERRNO, archiveCommand.c_str());
714 }
715 else
716 {
717 errorMsg.printf("Unexpected result (%d) while executing journal archive command: %s",
718 res, archiveCommand.c_str());
719 }
720
721 logPrimaryError(m_config->dbName, errorMsg);
722 return false;
723 }
724 }
725 else if (m_config->archiveDirectory.hasData())
726 {
727 const auto filename = segment->getFileName();
728 const auto archpathname = m_config->archiveDirectory + filename;
729
730 struct stat statistics;
731 if (os_utils::stat(archpathname.c_str(), &statistics) == 0)
732 {
733 if (statistics.st_size > (int) sizeof(SegmentHeader))

Callers

nothing calls this directly

Calls 12

executeShellFunction · 0.85
logPrimaryErrorFunction · 0.85
logPrimaryWarningFunction · 0.85
statClass · 0.70
hasDataMethod · 0.45
truncateMethod · 0.45
getFileNameMethod · 0.45
findMethod · 0.45
printfMethod · 0.45
c_strMethod · 0.45
copyToMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected