Skip to content

Commit

Permalink
hook delete dir in encrypted env (facebook#334) (#12)
Browse files Browse the repository at this point in the history
apache/incubator-pegasus#1575

Cherry-pick from
tikv@acc624f

* hook delete dir in encrypted env
* add a comment

Signed-off-by: tabokie <[email protected]>
Co-authored-by: Xinye Tao <[email protected]>
  • Loading branch information
acelyc111 and tabokie committed Aug 16, 2023
1 parent 5efb80e commit f61f3ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions encryption/encryption.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<KeyManager>& key_manager) {
std::shared_ptr<AESEncryptionProvider> provider(
Expand Down
2 changes: 2 additions & 0 deletions include/rocksdb/encryption.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<KeyManager> key_manager_;
const std::shared_ptr<AESEncryptionProvider> provider_;
Expand Down

0 comments on commit f61f3ea

Please sign in to comment.