[keel] Add missing error checking to pack
This commit is contained in:
parent
c78d3cf638
commit
dc6605fd48
@ -15,16 +15,22 @@ static ox::Error pathToInode(
|
||||
ox::FileSystem &dest,
|
||||
ox::ModelObject &obj) noexcept {
|
||||
auto &o = obj;
|
||||
auto type = static_cast<ox::FileAddressType>(o.at("type").unwrap()->get<int8_t>());
|
||||
auto &data = o.at("data").unwrap()->get<ox::ModelUnion>();
|
||||
oxRequire(typeVal, o.at("type"));
|
||||
auto const type = static_cast<ox::FileAddressType>(typeVal->get<int8_t>());
|
||||
oxRequire(dataVal, o.at("data"));
|
||||
auto &data = dataVal->get<ox::ModelUnion>();
|
||||
ox::String path;
|
||||
switch (type) {
|
||||
case ox::FileAddressType::Path:
|
||||
path = data.at("path").unwrap()->get<ox::String>();
|
||||
case ox::FileAddressType::Path: {
|
||||
oxRequire(pathVal, data.at("path"));
|
||||
path = pathVal->get<ox::String>();
|
||||
break;
|
||||
case ox::FileAddressType::ConstPath:
|
||||
path = data.at("constPath").unwrap()->get<ox::String>();
|
||||
}
|
||||
case ox::FileAddressType::ConstPath: {
|
||||
oxRequire(pathVal, data.at("constPath"));
|
||||
path = pathVal->get<ox::String>();
|
||||
break;
|
||||
}
|
||||
case ox::FileAddressType::Inode:
|
||||
case ox::FileAddressType::None:
|
||||
return {};
|
||||
@ -34,7 +40,7 @@ static ox::Error pathToInode(
|
||||
oxReturnError(keel::uuidToPath(ctx, uuid).to<ox::String>().moveTo(path));
|
||||
}
|
||||
oxRequire(s, dest.stat(path));
|
||||
oxReturnError(o.at("type").unwrap()->set(static_cast<int8_t>(ox::FileAddressType::Inode)));
|
||||
oxReturnError(typeVal->set(static_cast<int8_t>(ox::FileAddressType::Inode)));
|
||||
oxOutf("\tpath to inode: {} => {}\n", path, s.inode);
|
||||
return data.set(2, s.inode);
|
||||
}
|
||||
@ -162,12 +168,12 @@ static ox::Error copy(
|
||||
// copy
|
||||
oxRequire(fileList, src.ls(path));
|
||||
for (auto const&name : fileList) {
|
||||
auto currentFile = ox::sfmt("{}{}", path, name);
|
||||
auto const currentFile = ox::sfmt("{}{}", path, name);
|
||||
if (beginsWith(name, ".")) {
|
||||
continue;
|
||||
}
|
||||
oxRequire(stat, src.stat(currentFile));
|
||||
if (stat.fileType == ox::FileType::Directory) {
|
||||
oxRequire(srcStat, src.stat(currentFile));
|
||||
if (srcStat.fileType == ox::FileType::Directory) {
|
||||
oxReturnError(dest.mkdir(currentFile, true));
|
||||
oxReturnError(copy(manifest, src, dest, currentFile + '/', childLogPrefix));
|
||||
} else {
|
||||
@ -181,9 +187,9 @@ static ox::Error copy(
|
||||
// write file to dest
|
||||
oxReturnError(dest.write(currentFile, buff));
|
||||
status = "OK";
|
||||
oxRequire(stat, dest.stat(currentFile));
|
||||
oxRequire(dstStat, dest.stat(currentFile));
|
||||
manifest.files[currentFile] = {
|
||||
.inode = stat.inode,
|
||||
.inode = dstStat.inode,
|
||||
.type = ox::String{keel::readAssetTypeId(buff).or_value({})},
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user