mirror of
https://github.com/ohwgiles/laminar.git
synced 2024-10-27 20:34:20 +00:00
Allow subdirs in artifacts directory
Extend populateArtifacts() with a subdir parameter (default initialized to ".") to allow for recursive calls. With subdirs encountered, call recursively.
This commit is contained in:
parent
9b8c3762ec
commit
7e77ec1211
@ -203,18 +203,21 @@ std::list<std::string> Laminar::listKnownJobs() {
|
||||
return res;
|
||||
}
|
||||
|
||||
void Laminar::populateArtifacts(Json &j, std::string job, uint num) const {
|
||||
void Laminar::populateArtifacts(Json &j, std::string job, uint num, kj::Path subdir) const {
|
||||
kj::Path runArchive{job,std::to_string(num)};
|
||||
runArchive = runArchive.append(subdir);
|
||||
KJ_IF_MAYBE(dir, fsHome->tryOpenSubdir("archive"/runArchive)) {
|
||||
for(kj::StringPtr file : (*dir)->listNames()) {
|
||||
kj::FsNode::Metadata meta = (*dir)->lstat(kj::Path{file});
|
||||
if(meta.type != kj::FsNode::Type::FILE)
|
||||
continue;
|
||||
if(meta.type == kj::FsNode::Type::FILE) {
|
||||
j.StartObject();
|
||||
j.set("url", archiveUrl + (runArchive/file).toString().cStr());
|
||||
j.set("filename", file.cStr());
|
||||
j.set("filename", (subdir/file).toString().cStr());
|
||||
j.set("size", meta.size);
|
||||
j.EndObject();
|
||||
} else if(meta.type == kj::FsNode::Type::DIRECTORY) {
|
||||
populateArtifacts(j, job, num, subdir/file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ private:
|
||||
bool tryStartRun(std::shared_ptr<Run> run, int queueIndex);
|
||||
void handleRunFinished(Run*);
|
||||
// expects that Json has started an array
|
||||
void populateArtifacts(Json& out, std::string job, uint num) const;
|
||||
void populateArtifacts(Json& out, std::string job, uint num, kj::Path subdir = kj::Path::parse(".")) const;
|
||||
|
||||
Run* activeRun(const std::string name, uint num) {
|
||||
auto it = activeJobs.byNameNumber().find(boost::make_tuple(name, num));
|
||||
|
Loading…
Reference in New Issue
Block a user