From 8ab89e194c6395bcad4ad18f8f22d317a92db7af Mon Sep 17 00:00:00 2001 From: Yingchun Lai Date: Tue, 8 Aug 2023 21:38:41 +0800 Subject: [PATCH] hook delete dir in encrypted env (#334) (#12) https://github.com/apache/incubator-pegasus/issues/1575 Cherry-pick from https://github.com/tikv/rocksdb/commit/acc624ff90e3cbaac73efe8a31635d2ce23345ff * hook delete dir in encrypted env * add a comment Signed-off-by: tabokie Co-authored-by: Xinye Tao --- encryption/encryption.cc | 10 ++++++++++ include/rocksdb/encryption.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/encryption/encryption.cc b/encryption/encryption.cc index 8f4dea32e7b..0bf7cd41103 100644 --- a/encryption/encryption.cc +++ b/encryption/encryption.cc @@ -539,6 +539,16 @@ Status KeyManagedEncryptedEnv::RenameFile(const std::string& src_fname, return s; } +Status KeyManagedEncryptedEnv::DeleteDir(const std::string& dname) { + Status s = target()->DeleteDir(dname); + if (!s.ok()) { + return s; + } + // We don't use a dedicated `DeleteDir` function, because RocksDB already uses + // `RenameFile` for both file and directory. + return key_manager_->DeleteFile(dname); +} + Env* NewKeyManagedEncryptedEnv(Env* base_env, std::shared_ptr& key_manager) { std::shared_ptr provider( diff --git a/include/rocksdb/encryption.h b/include/rocksdb/encryption.h index 75977f13e6d..8bfac6ff134 100644 --- a/include/rocksdb/encryption.h +++ b/include/rocksdb/encryption.h @@ -97,6 +97,8 @@ class KeyManagedEncryptedEnv : public EnvWrapper { Status RenameFile(const std::string& src_fname, const std::string& dst_fname) override; + Status DeleteDir(const std::string& dname) override; + private: const std::shared_ptr key_manager_; const std::shared_ptr provider_;