Introduce time-out!

master
Melroy van den Berg 2020-12-14 22:54:11 +01:00
parent d272b0b28f
commit 8165c654d8
2 changed files with 5 additions and 5 deletions

View File

@ -138,15 +138,15 @@ void MainWindow::refresh()
*/
void MainWindow::fetchFromIPFS()
{
// TODO: In a seperate thread/process?
// Since otherwise this may block the UI.
// TODO: Execute the code in a seperate thread/process?
// Since otherwise this may block the UI if it takes too long!
try {
currentContent = m_file.fetch(finalRequestPath);
cmark_node* doc = Parser::parseContent(currentContent);
m_renderArea.processDocument(doc);
cmark_node_free(doc);
} catch (const std::runtime_error &error) {
std::cerr << "Error: IPFS Deamon is most likely down: " << error.what() << std::endl;
std::cerr << "Error: IPFS request failed, with message: " << error.what() << std::endl;
// Not found (or any other issue)
m_renderArea.showMessage("Page not found!", "Detailed error message: " + std::string(error.what()));
}

View File

@ -3,8 +3,8 @@
#include <sstream>
#include <iostream>
// Connect to IPFS daemon
Network::Network(): m_client("localhost", 5001) {}
// Connect to IPFS daemon (with 3 seconds time-out during requests)
Network::Network(): m_client("localhost", 5001, "3s") {}
/**
* Fetch a file from IPFS network