Compare commits

..

3 Commits

Author SHA1 Message Date
791988d1f9
Fix #64
All checks were successful
/ Build the server (push) Successful in 3m7s
2023-10-23 14:03:37 +02:00
3fb17e6fec
Fix #63 2023-10-23 14:00:14 +02:00
ee059a9747
Remove debug messages 2023-10-23 13:59:50 +02:00
6 changed files with 9 additions and 5 deletions

View File

@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import {Button, Spinner} from 'flowbite-svelte'; import {Button, Spinner} from 'flowbite-svelte';
import {Download} from 'carbon-icons-svelte'; import {Download} from 'carbon-icons-svelte';
import {api, rpc, token, workingWrapperR} from '../store'; import {api, download, rpc, token, workingWrapperR} from '../store';
import {onDestroy} from 'svelte'; import {onDestroy} from 'svelte';
export let node: api.Node; export let node: api.Node;
@ -38,7 +38,7 @@
onDestroy(() => { if (src.startsWith('blob')) URL.revokeObjectURL(src); }); onDestroy(() => { if (src.startsWith('blob')) URL.revokeObjectURL(src); });
</script> </script>
<Button class="w-full mb-6"><Download />Download</Button> <Button class="w-full mb-6" on:click={() => download($token ?? '', [node])}><Download />Download</Button>
{#if can_display && !loading && src === ''} {#if can_display && !loading && src === ''}
<Button class="w-full" outline on:click={load}>Load</Button> <Button class="w-full" outline on:click={load}>Load</Button>
{:else if loading} {:else if loading}

View File

@ -48,7 +48,7 @@ struct Token {
}; };
struct Config { struct Config {
std::string smtp_host, smtp_user, smtp_pass, smtp_from, admin_mail; // TODO: Send mail to admin on crash std::string smtp_host, smtp_user, smtp_pass, smtp_from, admin_mail;
std::uint16_t smtp_port, server_port; std::uint16_t smtp_port, server_port;
}; };

View File

@ -17,7 +17,6 @@ SaveNode load_node(const rapidjson::Value &doc) {
ASSIGN_MEMBER(node->id, id, Uint64); ASSIGN_MEMBER(node->id, id, Uint64);
id = node->id; id = node->id;
data_logger->debug("Loading node {}", id);
ASSIGN_MEMBER(node->name, name, String); ASSIGN_MEMBER(node->name, name, String);
ASSIGN_MEMBER(node->file, file, Bool); ASSIGN_MEMBER(node->file, file, Bool);

View File

@ -21,6 +21,7 @@ void signal_shutdown(const int) {
} }
int main() { int main() {
// TODO add current timestamp to log name
auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>("log.txt"); auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>("log.txt");
spdlog::default_logger()->sinks().push_back(file_sink); spdlog::default_logger()->sinks().push_back(file_sink);
spdlog::set_level(spdlog::level::trace); spdlog::set_level(spdlog::level::trace);

View File

@ -58,7 +58,9 @@ static const std::unordered_map<std::string, std::string> mime_type_map = {
static const std::string& get_mime_type(const std::filesystem::path &filename) { static const std::string& get_mime_type(const std::filesystem::path &filename) {
static const std::string octet = "application/octet-stream"; static const std::string octet = "application/octet-stream";
const auto &entry = mime_type_map.find(filename.extension()); std::string ext = filename.extension();
std::transform(ext.begin(), ext.end(), ext.begin(), [](auto c) { return std::tolower(c); });
const auto &entry = mime_type_map.find(ext);
if (entry != mime_type_map.end()) if (entry != mime_type_map.end())
return entry->second; return entry->second;
else else

View File

@ -5,9 +5,11 @@
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
// TODO implement backtrace // TODO implement backtrace
// TODO Send mail to admin on crash
[[noreturn]] [[noreturn]]
static void crash(std::source_location loc = std::source_location::current()) { static void crash(std::source_location loc = std::source_location::current()) {
spdlog::critical("crash called from: {}:{} `{}`", loc.file_name(), loc.line(), loc.function_name()); spdlog::critical("crash called from: {}:{} `{}`", loc.file_name(), loc.line(), loc.function_name());
spdlog::details::registry::instance().flush_all();
spdlog::shutdown(); spdlog::shutdown();
std::abort(); std::abort();
} }