From 5b9b053c616104b514e42925f3fc43d8cdc295f5 Mon Sep 17 00:00:00 2001 From: kssenii Date: Fri, 13 May 2022 13:22:29 +0200 Subject: [PATCH] Fix encrypted --- src/Disks/DiskEncrypted.cpp | 2 ++ src/Disks/IO/AsynchronousReadIndirectBufferFromRemoteFS.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/Disks/DiskEncrypted.cpp b/src/Disks/DiskEncrypted.cpp index 4ac59af95ab..ad6aa47fb59 100644 --- a/src/Disks/DiskEncrypted.cpp +++ b/src/Disks/DiskEncrypted.cpp @@ -287,6 +287,7 @@ std::unique_ptr DiskEncrypted::readFile( { auto wrapped_path = wrappedPath(path); auto buffer = delegate->readFile(wrapped_path, settings, read_hint, file_size); + buffer->setReadUntilPosition(FileEncryption::Header::kSize); if (buffer->eof()) { /// File is empty, that's a normal case, see DiskEncrypted::truncateFile(). @@ -296,6 +297,7 @@ std::unique_ptr DiskEncrypted::readFile( auto encryption_settings = current_settings.get(); FileEncryption::Header header = readHeader(*buffer); String key = getKey(path, header, *encryption_settings); + buffer->setReadUntilPosition(0); /// Reset position back. return std::make_unique(settings.local_fs_buffer_size, std::move(buffer), key, header); } diff --git a/src/Disks/IO/AsynchronousReadIndirectBufferFromRemoteFS.cpp b/src/Disks/IO/AsynchronousReadIndirectBufferFromRemoteFS.cpp index 8ac576be61c..d8552c3c95b 100644 --- a/src/Disks/IO/AsynchronousReadIndirectBufferFromRemoteFS.cpp +++ b/src/Disks/IO/AsynchronousReadIndirectBufferFromRemoteFS.cpp @@ -142,6 +142,12 @@ void AsynchronousReadIndirectBufferFromRemoteFS::setReadUntilPosition(size_t pos prefetch_future = {}; } + if (position == 0) + { + read_until_position.reset(); + return; + } + if (position > read_until_position) { read_until_position = position;