Skip to content

Commit

Permalink
On MacOS, writing more than 0x7fffffff bytes will fail with errno 22 (t…
Browse files Browse the repository at this point in the history
  • Loading branch information
neodix42 authored Jul 14, 2023
1 parent afb630b commit 50d2361
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions validator/db/files-async.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ class WriteFile : public td::actor::Actor {
: tmp_dir_(tmp_dir), new_name_(new_name), promise_(std::move(promise)) {
write_data_ = [data_ptr = std::make_shared<td::BufferSlice>(std::move(data))] (td::FileFd& fd) {
auto data = std::move(*data_ptr);
td::uint64 offset = 0;
while (data.size() > 0) {
TRY_RESULT(s, fd.pwrite(data.as_slice(), offset));
offset += s;
auto piece_size = std::min<size_t>(data.size(), 1 << 30);
TRY_RESULT(s, fd.write(data.as_slice().substr(0, piece_size)));
data.confirm_read(s);
}
return td::Status::OK();
Expand Down

0 comments on commit 50d2361

Please sign in to comment.