1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2026-10-17 08:40:54 +00:00

Replace boost/filesystem with kj/filesystem

Lose the boost dependency since recent versions of capnproto's kj
also provide a nice filesystem library. Take the opportunity to
refactor the Run object to become more than POD and to encapsulate
some of the functionality that was done in the Laminar class

Part of #49 refactor
This commit is contained in:
Oliver Giles
2018-09-28 10:36:10 +03:00
parent fe57d63623
commit 08b3f25a22
14 changed files with 332 additions and 308 deletions

View File

@@ -96,7 +96,7 @@ public:
}
std::shared_ptr<Run> run = laminar.queueJob(jobName, params);
if(Run* r = run.get()) {
return r->started.promise.then([context,r]() mutable {
return r->whenStarted().then([context,r]() mutable {
context.getResults().setResult(LaminarCi::MethodResult::SUCCESS);
context.getResults().setBuildNum(r->build);
});
@@ -314,11 +314,11 @@ private:
std::string badge;
responseHeaders.clear();
if(resource.compare(0, strlen("/archive/"), "/archive/") == 0) {
kj::Own<MappedFile> file = laminar.getArtefact(resource.substr(strlen("/archive/")));
if(file->address() != nullptr) {
KJ_IF_MAYBE(file, laminar.getArtefact(resource.substr(strlen("/archive/")))) {
auto array = (*file)->mmap(0, (*file)->stat().size);
responseHeaders.add("Content-Transfer-Encoding", "binary");
auto stream = response.send(200, "OK", responseHeaders, file->size());
return stream->write(file->address(), file->size()).attach(kj::mv(file)).attach(kj::mv(stream));
auto stream = response.send(200, "OK", responseHeaders, array.size());
return stream->write(array.begin(), array.size()).attach(kj::mv(array)).attach(kj::mv(file)).attach(kj::mv(stream));
}
} else if(resource.compare("/custom/style.css") == 0) {
responseHeaders.set(kj::HttpHeaderId::CONTENT_TYPE, "text/css; charset=utf-8");