diff --git a/env/env_encryption.cc b/env/env_encryption.cc index ca2542abb..8eec392ae 100644 --- a/env/env_encryption.cc +++ b/env/env_encryption.cc @@ -646,6 +646,15 @@ class EncryptedEnvImpl : public EnvWrapper { if (!status.ok()) { return status; } + uint64_t file_size; + status = EnvWrapper::GetFileSize(fname, &file_size); + if (!status.ok()) { + return status; + } + if (!file_size) { + *result = std::move(underlying); + return status; + } // Create cipher stream std::unique_ptr stream; size_t prefix_length; @@ -830,7 +839,7 @@ class EncryptedEnvImpl : public EnvWrapper { virtual Status GetFileSize(const std::string& fname, uint64_t* file_size) override { auto status = EnvWrapper::GetFileSize(fname, file_size); - if (!status.ok()) { + if (!status.ok() || !(*file_size)) { return status; } EncryptionProvider* provider;