5 #define __STDC_FORMAT_MACROS
17 namespace swissknife {
22 CommandScrub::CommandScrub() : machine_readable_output_(false), alerts_(0) {
41 return "unexpected regular file";
43 return "unexpected symlink";
45 return "unexpected subdir in CAS subdir";
47 return "unknown object modifier";
49 return "malformed content hash";
51 return "malformed CAS subdir length";
53 return "mismatch of file name and content hash";
55 return "unknown alert";
60 const std::string &file_name) {
61 assert(!file_name.empty());
63 if (relative_path.empty()) {
72 const string full_path =
MakeFullPath(relative_path, file_name);
74 file_name, full_path);
75 if (hash_string.empty()) {
93 const std::string &dir_name) {
94 const string full_path =
MakeFullPath(relative_path, dir_name);
97 if (
HasSuffix(full_path,
"data/txn/receiver",
false)) {
102 if (relative_path.size() > 0) {
115 const std::string &symlink_name) {
116 const string full_path =
MakeFullPath(relative_path, symlink_name);
121 const string full_path = scrubbing_result.
path;
125 assert(!file_name.empty());
128 file_name, full_path);
129 assert(!hash_string.empty());
133 if (scrubbing_result.
hash
141 const std::string &relative_path,
142 const std::string &file_name,
143 const std::string &full_path)
const {
145 const char last_character = *(file_name.end() - 1);
146 bool has_object_modifier =
false;
147 if (std::isupper(last_character)) {
148 has_object_modifier =
true;
161 + (has_object_modifier
162 ? file_name.substr(0,
163 file_name.length() - 1)
190 const std::string &path,
191 const std::string &affected_hash)
const {
197 ((affected_hash.empty()) ?
"-" : affected_hash.c_str()),
207 const std::string &file_name)
const {
208 return (relative_path.empty())
210 :
repo_path_ +
"/" + relative_path +
"/" + file_name;
215 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,...)