5 #define __STDC_FORMAT_MACROS
8 #include "cvmfs_config.h"
18 namespace swissknife {
23 CommandScrub::CommandScrub()
24 : machine_readable_output_(false)
47 return "unexpected regular file";
49 return "unexpected symlink";
51 return "unexpected subdir in CAS subdir";
53 return "unknown object modifier";
55 return "malformed content hash";
57 return "malformed CAS subdir length";
59 return "mismatch of file name and content hash";
61 return "unknown alert";
66 const std::string &relative_path,
67 const std::string &file_name)
69 assert(!file_name.empty());
71 if (relative_path.empty()) {
80 const string full_path =
MakeFullPath(relative_path, file_name);
81 const std::string hash_string =
83 if (hash_string.empty()) {
103 const std::string &relative_path,
104 const std::string &dir_name)
106 const string full_path =
MakeFullPath(relative_path, dir_name);
109 if (
HasSuffix(full_path,
"data/txn/receiver",
false)) {
114 if (relative_path.size() > 0) {
127 const std::string &symlink_name) {
128 const string full_path =
MakeFullPath(relative_path, symlink_name);
133 const string full_path = scrubbing_result.
path;
137 assert(!file_name.empty());
139 const std::string hash_string =
141 assert(!hash_string.empty());
145 if (scrubbing_result.
hash !=
154 const std::string &relative_path,
155 const std::string &file_name,
156 const std::string &full_path)
const
159 const char last_character = *(file_name.end() - 1);
160 bool has_object_modifier =
false;
161 if (std::isupper(last_character)) {
162 has_object_modifier =
true;
174 const string hash_string =
176 (has_object_modifier ? file_name.substr(0, file_name.length() - 1)
204 const std::string &path,
205 const std::string &affected_hash)
const
212 ((affected_hash.empty()) ?
"-" : affected_hash.c_str()),
222 const std::string &file_name)
const {
223 return (relative_path.empty())
225 :
repo_path_ +
"/" + relative_path +
"/" + file_name;
230 return full_path.substr(
repo_path_.length() + 1);
const size_t kHashSubtreeLength
CallbackPtr RegisterListener(typename BoundClosure< ParamT, DelegateT, ClosureDataT >::CallbackMethod method, DelegateT *delegate, ClosureDataT data)
void FileCallback(const std::string &relative_path, const std::string &file_name)
static Parameter Switch(const char key, const std::string &desc)
NameString GetFileName(const PathString &path)
VoidCallback fn_new_symlink
void DirCallback(const std::string &relative_path, const std::string &dir_name)
void Recurse(const std::string &dir_path) const
std::vector< Parameter > ParameterList
const char kSuffixCertificate
std::string ToString(const bool with_suffix=false) const
virtual ParameterList GetParams() const
void OnFileHashed(const ScrubbingResult &scrubbing_result)
const char kSuffixMicroCatalog
A simple recursion engine to abstract the recursion of directories. It provides several callback hook...
void Process(IngestionSource *source, shash::Algorithms hash_algorithm, shash::Suffix hash_suffix)
void SymlinkCallback(const std::string &relative_path, const std::string &symlink_name)
assert((mem||(size==0))&&"Out Of Memory")
std::string MakeFullPath(const std::string &relative_path, const std::string &file_name) const
void PrintAlert(const Alerts::Type type, const std::string &path, const std::string &affected_hash="") const
const char kSuffixPartial
VoidCallback fn_enter_dir
static Parameter Mandatory(const char key, const std::string &desc)
bool HasSuffix(const std::string &str, const std::string &suffix, const bool ignore_case)
const char kSuffixCatalog
std::string MakeRelativePath(const std::string &full_path)
ScrubbingPipeline pipeline_scrubbing_
pthread_mutex_t alerts_mutex_
const char kSuffixMetainfo
bool HasPrefix(const string &str, const string &prefix, const bool ignore_case)
const char kSuffixHistory
std::string CheckPathAndExtractHash(const std::string &relative_path, const std::string &file_name, const std::string &full_path) const
std::map< char, SharedPtr< std::string > > ArgumentList
Any MkFromSuffixedHexPtr(const HexPtr hex)
PathString GetParentPath(const PathString &path)
static const char * ToString(const Type t)
int Main(const ArgumentList &args)
std::string MakeCanonicalPath(const std::string &path)
const std::string kTxnDirectoryName
bool machine_readable_output_
void ShowAlertsHelpMessage() const
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)