mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
Merge pull request #48578 from ClickHouse/slightly-optimize-install
Slightly optimize Install
This commit is contained in:
commit
51688bb771
@ -375,15 +375,22 @@ int mainEntryClickHouseInstall(int argc, char ** argv)
|
||||
|
||||
try
|
||||
{
|
||||
ReadBufferFromFile in(binary_self_path.string());
|
||||
WriteBufferFromFile out(main_bin_tmp_path.string());
|
||||
copyData(in, out);
|
||||
out.sync();
|
||||
String source = binary_self_path.string();
|
||||
String destination = main_bin_tmp_path.string();
|
||||
|
||||
if (0 != fchmod(out.getFD(), S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH))
|
||||
/// Try to make a hard link first, as an optimization.
|
||||
/// It is possible if the source and the destination are on the same filesystems.
|
||||
if (0 != link(source.c_str(), destination.c_str()))
|
||||
{
|
||||
ReadBufferFromFile in(binary_self_path.string());
|
||||
WriteBufferFromFile out(main_bin_tmp_path.string());
|
||||
copyData(in, out);
|
||||
out.sync();
|
||||
out.finalize();
|
||||
}
|
||||
|
||||
if (0 != chmod(destination.c_str(), S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH))
|
||||
throwFromErrno(fmt::format("Cannot chmod {}", main_bin_tmp_path.string()), ErrorCodes::SYSTEM_ERROR);
|
||||
|
||||
out.finalize();
|
||||
}
|
||||
catch (const Exception & e)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user