1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. 2 // This source code is licensed under both the GPLv2 (found in the 3 // COPYING file in the root directory) and Apache 2.0 License 4 // (found in the LICENSE.Apache file in the root directory). 5 // 6 // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 7 // Use of this source code is governed by a BSD-style license that can be 8 // found in the LICENSE file. See the AUTHORS file for names of contributors. 9 10 #ifdef GFLAGS 11 #pragma once 12 #include "db_stress_tool/db_stress_common.h" 13 14 namespace ROCKSDB_NAMESPACE { 15 class DbStressEnvWrapper : public EnvWrapper { 16 public: DbStressEnvWrapper(Env * t)17 explicit DbStressEnvWrapper(Env* t) : EnvWrapper(t) {} 18 DeleteFile(const std::string & f)19 Status DeleteFile(const std::string& f) override { 20 // We determine whether it is a manifest file by searching a strong, 21 // so that there will be false positive if the directory path contains the 22 // keyword but it is unlikely. 23 // Checkpoint directory needs to be exempted. 24 if (!if_preserve_all_manifests || 25 f.find("MANIFEST-") == std::string::npos || 26 f.find("checkpoint") != std::string::npos) { 27 return target()->DeleteFile(f); 28 } 29 return Status::OK(); 30 } 31 32 // If true, all manifest files will not be delted in DeleteFile(). 33 bool if_preserve_all_manifests = true; 34 }; 35 } // namespace ROCKSDB_NAMESPACE 36 #endif // GFLAGS 37