fix: do not write modified_by if the name matches the author (#375)

fix: do not write modified_by if the name matches the author
fix: missing empty author string check
This commit is contained in:
Владислав Сухов 2022-10-10 01:51:32 +06:00 committed by GitHub
commit b80bb538af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1792,7 +1792,10 @@ template <typename U> bool BotGraph::loadStorage (StringRef ext, StringRef name,
strings.copy (m_extenHeader.author, exten->author, cr::bufsize (exten->author)); strings.copy (m_extenHeader.author, exten->author, cr::bufsize (exten->author));
if (extenSize <= actuallyRead) { if (extenSize <= actuallyRead) {
strings.copy (m_extenHeader.modified, exten->modified, cr::bufsize (exten->modified)); // write modified by, only if the name is different
if (!strings.isEmpty (m_extenHeader.author) && strncmp (m_extenHeader.author, exten->modified, cr::bufsize (m_extenHeader.author)) != 0) {
strings.copy (m_extenHeader.modified, exten->modified, cr::bufsize (exten->modified));
}
} }
else { else {
strings.copy (m_extenHeader.modified, "(none)", cr::bufsize (exten->modified)); strings.copy (m_extenHeader.modified, "(none)", cr::bufsize (exten->modified));
@ -1889,7 +1892,7 @@ bool BotGraph::saveGraphData () {
} }
ExtenHeader exten {}; ExtenHeader exten {};
// only modify the author if no author currenlty assigned to graph file // only modify the author if no author currently assigned to graph file
if (m_graphAuthor.empty () || strings.isEmpty (m_extenHeader.author)) { if (m_graphAuthor.empty () || strings.isEmpty (m_extenHeader.author)) {
strings.copy (exten.author, editorName.chars (), cr::bufsize (exten.author)); strings.copy (exten.author, editorName.chars (), cr::bufsize (exten.author));
} }