don't try to save RouterInfo if no buffer

This commit is contained in:
orignal 2023-02-12 19:10:22 -05:00
parent d15581d95e
commit c2faa5c614
2 changed files with 10 additions and 4 deletions

View File

@ -279,6 +279,7 @@ namespace data
if (!r->Update (buf, len))
{
updated = false;
m_Requests.RequestComplete (ident, r);
return r;
}
if (r->IsUnreachable ())
@ -290,6 +291,7 @@ namespace data
std::unique_lock<std::mutex> l(m_FloodfillsMutex);
m_Floodfills.remove (r);
}
m_Requests.RequestComplete (ident, nullptr);
return nullptr;
}
}
@ -645,10 +647,14 @@ namespace data
std::string ident = it.second->GetIdentHashBase64();
if (it.second->IsUpdated ())
{
it.second->SaveToFile (m_Storage.Path(ident));
if (it.second->GetBuffer ())
{
// we have something to save
it.second->SaveToFile (m_Storage.Path(ident));
it.second->SetUnreachable (false);
it.second->DeleteBuffer ();
}
it.second->SetUpdated (false);
it.second->SetUnreachable (false);
it.second->DeleteBuffer ();
updatedCount++;
continue;
}

View File

@ -242,7 +242,7 @@ namespace data
void SetUnreachable (bool unreachable) { m_IsUnreachable = unreachable; };
bool IsUnreachable () const { return m_IsUnreachable; };
const uint8_t * GetBuffer () const { return m_Buffer->data (); };
const uint8_t * GetBuffer () const { return m_Buffer ? m_Buffer->data () : nullptr; };
const uint8_t * LoadBuffer (const std::string& fullPath); // load if necessary
size_t GetBufferLen () const { return m_BufferLen; };