use std::format in logger, re-organize main.cpp, add SIGINT handling.
This commit is contained in:
@@ -43,10 +43,9 @@ public:
|
||||
cwd = "/";
|
||||
|
||||
} catch (const fs::filesystem_error& ex) {
|
||||
logger->print(LOGLEVEL_ERROR, "setRoot error: %s", ex.what());
|
||||
logger->print(LOGLEVEL_ERROR, "setRoot error: {}", ex.what());
|
||||
fd.error = {FilerStatusCodes::Exception, ex.what()};
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
@@ -68,7 +67,7 @@ public:
|
||||
|
||||
cwd = new_cwd;
|
||||
} catch (const fs::filesystem_error& ex) {
|
||||
logger->print(LOGLEVEL_ERROR, "setCWD error: %s", ex.what());
|
||||
logger->print(LOGLEVEL_ERROR, "setCWD error: {}", ex.what());
|
||||
fd.error = {FilerStatusCodes::Exception, ex.what()};
|
||||
}
|
||||
|
||||
@@ -105,16 +104,16 @@ public:
|
||||
*target = fs::path(*target).lexically_normal();
|
||||
if (fs::is_symlink(*target) && resolve_symlink) {
|
||||
fs::path resolved_sym = fs::weakly_canonical(*target);
|
||||
logger->print(LOGLEVEL_DEBUG, "Resolved symlink path: %s", resolved_sym.c_str());
|
||||
logger->print(LOGLEVEL_DEBUG, "resolved symlink path: {}", resolved_sym.string());
|
||||
return resolve_ext_symlinks ? true : resolved_sym.string().starts_with(root.string());
|
||||
} else if (!(*target).string().starts_with(root.string()))
|
||||
return false;
|
||||
|
||||
logger->print(LOGLEVEL_DEBUG, "Resolved path: %s", target->c_str());
|
||||
logger->print(LOGLEVEL_DEBUG, "resolved path: {}", target->string());
|
||||
|
||||
return true;
|
||||
} catch (const std::exception& e) {
|
||||
logger->print(LOGLEVEL_ERROR, "Path resolution error: %s", e.what());
|
||||
logger->print(LOGLEVEL_ERROR, "path resolution error: {}", e.what());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -151,7 +150,7 @@ public:
|
||||
fd.path = strdup(requested_path.c_str());
|
||||
fd.relpath = strdup(fs::relative(requested_path, root).c_str());
|
||||
} catch (const fs::filesystem_error& ex) {
|
||||
logger->print(LOGLEVEL_ERROR, "Path fallback: %s", ex.what());
|
||||
logger->print(LOGLEVEL_ERROR, "traversal error: {}", ex.what());
|
||||
fd.error = file_error{FilerStatusCodes::Exception, ex.what()};
|
||||
}
|
||||
return fd;
|
||||
|
||||
Reference in New Issue
Block a user