fix: CWD restore, install error checks, fetch EINTR
- build.cpp: save/restore CWD on both success and failure paths - install.cpp: check error_code after each filesystem op, abort on failure - install.cpp: check write_installed() return value - fetch.cpp: EINTR retry loop on both waitpid calls (exec_cmd + exec_capture)
This commit is contained in:
@@ -42,21 +42,26 @@ InstallResult install(const resolve::BuildStep& step,
|
||||
auto src = work_dir / "destdir";
|
||||
if (fs::exists(src)) {
|
||||
for (auto& entry : fs::recursive_directory_iterator(src, ec)) {
|
||||
if (ec) { break; }
|
||||
auto rel = fs::relative(entry.path(), src);
|
||||
auto target = dest / rel;
|
||||
if (entry.is_directory()) {
|
||||
fs::create_directories(target, ec);
|
||||
} else {
|
||||
fs::create_directories(target.parent_path(), ec);
|
||||
fs::rename(entry.path(), target, ec);
|
||||
if (!ec) { fs::rename(entry.path(), target, ec); }
|
||||
}
|
||||
if (ec) { break; }
|
||||
}
|
||||
}
|
||||
|
||||
auto entries = read_installed();
|
||||
entries.push_back({step.name, step.resolved.original.version,
|
||||
hash, step.resolved.original.provides});
|
||||
write_installed(entries);
|
||||
if (!write_installed(entries)) {
|
||||
result.error = "failed to write installed DB";
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::string> hashes;
|
||||
for (auto& e : entries) { hashes.push_back(e.hash); }
|
||||
|
||||
Reference in New Issue
Block a user