Util::hard_link(source, dest);
#ifndef _WIN32
if (chmod(dest.c_str(), 0444 & ~Util::get_umask()) != 0) {
- LOG("Failed to chmod: {}", strerror(errno));
+ LOG("Failed to chmod {}: {}", dest.c_str(), strerror(errno));
}
#endif
return;
} catch (const core::Error& e) {
- LOG_RAW(e.what());
+ LOG("Failed to hard link {} to {}: {}", source, dest, e.what());
// Fall back to copying.
}
}
#ifndef _WIN32
if (link(oldpath.c_str(), newpath.c_str()) != 0) {
- throw core::Error(
- FMT("failed to link {} to {}: {}", oldpath, newpath, strerror(errno)));
+ throw core::Error(strerror(errno));
}
#else
if (!CreateHardLink(newpath.c_str(), oldpath.c_str(), nullptr)) {
- DWORD error = GetLastError();
- throw core::Error(FMT("failed to link {} to {}: {}",
- oldpath,
- newpath,
- Win32Util::error_message(error)));
+ throw core::Error(Win32Util::error_message(GetLastError()));
}
#endif
}
const auto dest_path = get_dest_path(file_type);
if (!dest_path.empty()) {
- Util::clone_hard_link_or_copy_file(
- m_ctx.config, raw_file_path, dest_path, false);
+ try {
+ Util::clone_hard_link_or_copy_file(
+ m_ctx.config, raw_file_path, dest_path, false);
+ } catch (core::Error& e) {
+ throw WriteError(FMT("Failed to clone/link/copy {} to {}: {}",
+ raw_file_path,
+ dest_path,
+ e.what()));
+ }
// Update modification timestamp to save the file from LRU cleanup (and, if
// hard-linked, to make the object file newer than the source file).