5 #define __STDC_FORMAT_MACROS
36 AbstractSyncMediator::~AbstractSyncMediator() { }
41 : catalog_manager_(catalog_manager)
43 , handle_hardlinks_(false)
71 const bool ignore_case_setting =
false;
72 const string relative_path = entry->GetRelativePath();
76 ignore_case_setting))) {
78 relative_path.c_str());
90 if (entry->IsDirectory()) {
96 if (entry->IsBundleSpec()) {
98 "Bundles is currently an experimental feature.");
100 if (!entry->IsRegularFile()) {
103 if (entry->HasHardlinks()) {
104 PANIC(
kLogStderr,
"Error: .cvmfsbundles file must not be a hard link");
107 const std::string parent_path =
GetParentPath(entry->GetUnionPath());
110 "Error: .cvmfsbundles file must be in the root"
111 " directory of the repository. Found in %s",
112 parent_path.c_str());
115 std::string json_string;
117 const int fd = open(entry->GetUnionPath().c_str(), O_RDONLY);
120 entry->GetUnionPath().c_str());
124 entry->GetUnionPath().c_str());
132 if (entry->IsRegularFile() || entry->IsSymlink()) {
139 }
else if (entry->IsGraftMarker()) {
147 if (entry->IsSpecialFile() && !entry->IsWhiteout()) {
151 "is a special file, ignoring.");
162 +
"' cannot be added. Unrecognized file type.");
172 if (entry->IsGraftMarker()) {
175 if (entry->IsDirectory()) {
181 if (entry->IsRegularFile() || entry->IsSymlink() || entry->IsSpecialFile()) {
192 if (entry->WasSymlink()) {
196 if (entry->IsSymlink()) {
201 dif += entry->GetScratchSize();
206 dif -= entry->GetRdOnlySize();
207 if (entry->IsSymlink()) {
212 dif += entry->GetScratchSize();
225 +
"' cannot be touched. Unrecognized file type.");
235 if (entry->WasDirectory()) {
240 if (entry->WasBundleSpec()) {
246 if (entry->WasRegularFile() || entry->WasSymlink()
247 || entry->WasSpecialFile()) {
253 +
"' cannot be deleted. Unrecognized file type.");
300 "Waiting for upload of files before committing...");
333 i->master->GetUnionPath().c_str());
335 i->master->GetUnionPath());
346 i->master->GetUnionPath().c_str());
374 const string empty_file =
379 unlink(empty_file.c_str());
394 const uint64_t inode = entry->GetUnionInode();
396 inode, entry->GetUnionPath().c_str());
399 const HardlinkGroupMap::iterator hardlink_group =
408 hardlink_group->second.AddHardlink(entry);
412 if (entry->IsNew()) {
427 if (entry->GetUnionLinkcount() < 2)
430 const uint64_t inode = entry->GetUnionInode();
431 HardlinkGroupMap::iterator hl_group;
438 for (SyncItemList::const_iterator i = hl_group->second.hardlinks.begin(),
439 iEnd = hl_group->second.hardlinks.end();
442 if (*(i->second) == *entry) {
454 entry->GetUnionPath().c_str());
456 hl_group->second.AddHardlink(entry);
476 entry->GetUnionPath().c_str());
488 traversal.Recurse(entry->GetUnionPath());
493 const string &file_name) {
501 const string &file_name) {
508 const string &parent_dir,
const string &file_name) {
515 const string &file_name) {
522 const string &file_name) {
529 const string &file_name) {
553 traversal.Recurse(entry->GetScratchPath());
558 const std::string &dir_name) {
567 const std::string &file_name) {
575 const std::string &file_name) {
582 const std::string &file_name) {
589 const std::string &file_name) {
596 const std::string &file_name) {
603 const std::string &link_name) {
611 const std::string &dir_name) {
619 const std::string &dir_name) {
630 const bool recurse =
false;
640 traversal.Recurse(entry->GetRdOnlyPath());
648 const std::string &file_name) {
656 const std::string &link_name) {
663 const std::string &link_name) {
670 const std::string &link_name) {
677 const std::string &link_name) {
684 const std::string &link_name) {
691 const std::string &dir_name) {
699 const std::string &file_name) {
706 return entry->IsWhiteout();
710 const std::string &relative_parent_path,
const std::string &filename,
718 "Spooler callback for %s, digest %s, produced %lu chunks, retval %d",
726 SyncItemList::iterator itr;
748 item.relative_parent_path(),
754 item.relative_parent_path());
765 "Spooler callback for hardlink %s, digest %s, retval %d",
778 SyncItemList::iterator j, jend;
798 const std::string notice =
"Nested catalog at " + directory->GetUnionPath();
808 const std::string notice =
"Nested catalog at " + directory->GetUnionPath();
853 const char *action_label;
857 if (path.at(0) !=
'/') {
858 action_label =
"[x-catalog-add]";
860 action_label =
"[add]";
869 assert(
"Invalid print action.");
874 const char *action_label;
878 if (path.at(0) !=
'/') {
879 action_label =
"[x-catalog-rem]";
881 action_label =
"[rem]";
891 assert(
"Invalid print action.");
896 const char *action_label;
900 action_label =
"[mod]";
908 assert(
"Invalid print action.");
915 if ((entry->IsSymlink() || entry->IsSpecialFile()) && !
params_->
dry_run) {
916 assert(!entry->HasGraftMarker());
926 entry->relative_parent_path());
930 if (entry->IsValidGraft()) {
932 if (entry->IsChunkedGraft()) {
936 entry->relative_parent_path(),
937 *(entry->GetGraftChunks()));
943 entry->relative_parent_path());
950 "Encountered a grafted file (%s) with "
951 "invalid grafting information; check contents of .cvmfsgraft-*"
952 " file. Aborting publish.",
953 entry->GetRelativePath().c_str());
955 }
else if (entry->relative_parent_path().empty()
956 && entry->IsCatalogMarker()) {
969 if (entry->IsNew()) {
970 if (entry->IsSymlink()) {
985 entry->GetUnionPath().c_str());
992 if (entry->WasSymlink()) {
1005 if (entry->IsBundleSpec()) {
1007 "Illegal directory name: .cvmfsbundles (%s). "
1008 ".cvmfsbundles is reserved for bundles specification files",
1009 entry->GetUnionPath().c_str());
1015 assert(!entry->HasGraftMarker());
1024 entry->relative_parent_path());
1029 if (entry->HasCatalogMarker()
1042 const std::string directory_path = entry->GetRelativePath();
1060 const std::string directory_path = entry->GetRelativePath();
1075 if (entry->HasCatalogMarker()
1078 }
else if (!entry->HasCatalogMarker()
1091 for (HardlinkGroupMap::const_iterator i = hardlinks.begin(),
1092 iEnd = hardlinks.end();
1095 if (i->second.hardlinks.size() != i->second.master->GetUnionLinkcount()
1098 i->second.master->GetUnionPath().c_str());
1102 for (SyncItemList::const_iterator j = i->second.hardlinks.begin(),
1103 jEnd = i->second.hardlinks.end();
1106 const std::string changeset_notice =
1108 j->second->filename();
1116 if (i->second.master->IsSymlink() || i->second.master->IsSpecialFile())
1129 for (SyncItemList::const_iterator i = group.
hardlinks.begin(),
1133 hardlinks.push_back(
1143 group.
master->relative_parent_path(),
int return_code
the return value of the spooler operation
void ModifyImpl(const std::string &path)
void Dec(class Counter *counter)
void AddChunkedFile(const DirectoryEntryBase &entry, const XattrList &xattrs, const std::string &parent_directory, const FileChunkList &file_chunks)
const manifest::Manifest * manifest() const
int64_t Xadd(class Counter *counter, const int64_t delta)
void AddHardlinkGroup(const DirectoryEntryBaseList &entries, const XattrList &xattrs, const std::string &parent_directory, const FileChunkList &file_chunks)
FileChunkList file_chunks
the file chunks generated during processing
void AddDirectory(const DirectoryEntryBase &entry, const XattrList &xattrs, const std::string &parent_directory)
virtual bool SupportsHardlinks() const
void RemoveDirectory(const std::string &directory_path)
CVMFS_EXPORT const LogSource source
std::string ToString(const bool with_suffix=false) const
virtual void OnInit(const history::History::Tag &from_tag, const history::History::Tag &to_tag)
virtual void OnModify(const std::string &path, const catalog::DirectoryEntry &entry_from, const catalog::DirectoryEntry &entry_to)
FileChunkList file_chunks
std::string CreateTempPath(const std::string &path_prefix, const int mode)
std::string scratch_path() const
A simple recursion engine to abstract the recursion of directories. It provides several callback hook...
assert((mem||(size==0))&&"Out Of Memory")
bool Commit(const bool stop_for_tweaks, const uint64_t manual_revision, manifest::Manifest *manifest)
void RemoveImpl(const std::string &path)
virtual void PostUpload()
SharedPtr< SyncItem > CreateSyncItem(const std::string &relative_parent_path, const std::string &filename, const SyncItemType entry_type) const
bool IsTransitionPoint(const std::string &mountpoint)
void TouchDirectory(const DirectoryEntryBase &entry, const XattrList &xattrs, const std::string &directory_path)
std::string local_path
the local_path previously given as input
unsigned int processing_dot_interval_
std::string union_path() const
zlib::Algorithms compression_alg
static JsonDocument * Create(const std::string &text)
void ShrinkHardlinkGroup(const std::string &remove_path)
VoidCallback fn_enter_dir
virtual bool IgnoreFilePredicate(const std::string &parent_dir, const std::string &filename)
virtual void OnStats(const catalog::DeltaCounters &delta)
upload::Spooler * spooler
void AddImpl(const std::string &path)
static const int kActionNone
bool ignore_special_files
void PrintWarning(const string &message)
unsigned int changed_items_
void Inc(class Counter *counter)
bool HasPrefix(const string &str, const string &prefix, const bool ignore_case)
void Clone(const std::string from, const std::string to)
void RemoveFile(const std::string &file_path)
PrintAction print_action_
bool stop_for_catalog_tweaks
bool SafeReadToString(int fd, std::string *final_result)
void RemoveNestedCatalog(const std::string &mountpoint, const bool merge=true)
SharedPtr< SyncItem > master
virtual void OnRemove(const std::string &path, const catalog::DirectoryEntry &entry)
void SetContentHash(const shash::Any &hash)
PathString GetParentPath(const PathString &path)
std::vector< DirectoryEntryBase > DirectoryEntryBaseList
static XattrList * CreateFromFile(const std::string &path)
static const char * kVirtualPath
bool ignore_xdir_hardlinks
void AddFile(const DirectoryEntryBase &entry, const XattrList &xattrs, const std::string &parent_directory)
std::string rdonly_path() const
std::map< uint64_t, HardlinkGroup > HardlinkGroupMap
void PrecalculateListings()
void CreateNestedCatalog(const std::string &mountpoint)
bool IsBalanceable() const
virtual void OnAdd(const std::string &path, const catalog::DirectoryEntry &entry)
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)