|
9 | 9 | #ifndef LLVM_CAS_UNIFIEDONDISKCACHE_H |
10 | 10 | #define LLVM_CAS_UNIFIEDONDISKCACHE_H |
11 | 11 |
|
| 12 | +#include "llvm/CAS/BuiltinUnifiedCASDatabases.h" |
12 | 13 | #include "llvm/CAS/OnDiskGraphDB.h" |
13 | 14 |
|
14 | 15 | namespace llvm::cas::ondisk { |
@@ -82,6 +83,34 @@ class UnifiedOnDiskCache { |
82 | 83 | OnDiskGraphDB::FaultInPolicy FaultInPolicy = |
83 | 84 | OnDiskGraphDB::FaultInPolicy::FullTree); |
84 | 85 |
|
| 86 | + /// Validate the data in \p Path, if needed to ensure correctness. |
| 87 | + /// |
| 88 | + /// Note: if invalid data is detected and \p AllowRecovery is true, then |
| 89 | + /// recovery requires exclusive access to the CAS and it is an error to |
| 90 | + /// attempt recovery if there is concurrent use of the CAS. |
| 91 | + /// |
| 92 | + /// \param Path directory for the on-disk database. |
| 93 | + /// \param HashName Identifier name for the hashing algorithm that is going to |
| 94 | + /// be used. |
| 95 | + /// \param HashByteSize Size for the object digest hash bytes. |
| 96 | + /// \param CheckHash Whether to validate hashes match the data. |
| 97 | + /// \param AllowRecovery Whether to automatically recover from invalid data by |
| 98 | + /// marking the files for garbage collection. |
| 99 | + /// \param ForceValidation Whether to force validation to occur even if it |
| 100 | + /// should not be necessary. |
| 101 | + /// \param LLVMCasBinary If provided, validation is performed out-of-process |
| 102 | + /// using the given \c llvm-cas executable which protects against crashes |
| 103 | + /// during validation. Otherwise validation is performed in-process. |
| 104 | + /// |
| 105 | + /// \returns \c Valid if the data is already valid, \c RecoveredValid if data |
| 106 | + /// was invalid but has been cleared, \c Skipped if validation is not needed, |
| 107 | + /// or an \c Error if validation cannot be performed or if the data is left |
| 108 | + /// in an invalid state because \p AllowRecovery is false. |
| 109 | + static Expected<ValidationResult> |
| 110 | + validateIfNeeded(StringRef Path, StringRef HashName, unsigned HashByteSize, |
| 111 | + bool CheckHash, bool AllowRecovery, bool ForceValidation, |
| 112 | + std::optional<StringRef> LLVMCasBinary); |
| 113 | + |
85 | 114 | /// This is called implicitly at destruction time, so it is not required for a |
86 | 115 | /// client to call this. After calling \p close the only method that is valid |
87 | 116 | /// to call is \p needsGarbaseCollection. |
|
0 commit comments