diff --git a/src/Storages/StorageKeeperMap.cpp b/src/Storages/StorageKeeperMap.cpp index 1504656bce5..918649ffb00 100644 --- a/src/Storages/StorageKeeperMap.cpp +++ b/src/Storages/StorageKeeperMap.cpp @@ -1032,9 +1032,9 @@ void StorageKeeperMap::restoreDataImpl( if (!dynamic_cast(in.get())) { temp_data_file.emplace(temporary_disk); - auto out = std::make_unique(temp_data_file->getAbsolutePath()); - copyData(*in, *out); - out.reset(); + auto out = WriteBufferFromFile(temp_data_file->getAbsolutePath()); + copyData(*in, out); + out.finalize(); in = createReadBufferFromFileBase(temp_data_file->getAbsolutePath(), {}); } std::unique_ptr in_from_file{static_cast(in.release())};