From acc624ff90e3cbaac73efe8a31635d2ce23345ff Mon Sep 17 00:00:00 2001 From: Xinye Tao Date: Thu, 20 Apr 2023 10:43:13 +0800 Subject: [PATCH] hook delete dir in encrypted env (#334) * hook delete dir in encrypted env Signed-off-by: tabokie * add a comment Signed-off-by: tabokie --------- Signed-off-by: tabokie --- 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 00837cc055c..a60950569a7 100644 --- a/encryption/encryption.cc +++ b/encryption/encryption.cc @@ -536,6 +536,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_;