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 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 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 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());
378 unlink(empty_file.c_str());
393 uint64_t inode = entry->GetUnionInode();
395 inode, entry->GetUnionPath().c_str());
398 HardlinkGroupMap::iterator hardlink_group =
GetHardlinkMap().find(inode);
406 hardlink_group->second.AddHardlink(entry);
410 if (entry->IsNew()) {
425 if (entry->GetUnionLinkcount() < 2)
428 uint64_t inode = entry->GetUnionInode();
429 HardlinkGroupMap::iterator hl_group;
436 for (SyncItemList::const_iterator i = hl_group->second.hardlinks.begin(),
437 iEnd = hl_group->second.hardlinks.end();
440 if (*(i->second) == *entry) {
452 entry->GetUnionPath().c_str());
454 hl_group->second.AddHardlink(entry);
474 entry->GetUnionPath().c_str());
486 traversal.Recurse(entry->GetUnionPath());
491 const string &file_name) {
498 const string &file_name) {
505 const string &parent_dir,
const string &file_name) {
512 const string &file_name) {
519 const string &file_name) {
525 const string &file_name) {
549 traversal.Recurse(entry->GetScratchPath());
554 const std::string &dir_name) {
562 const std::string &file_name) {
569 const std::string &file_name) {
576 const std::string &file_name) {
583 const std::string &file_name) {
589 const std::string &file_name) {
596 const std::string &link_name) {
604 const std::string &dir_name) {
611 const std::string &dir_name) {
621 const bool recurse =
false;
631 traversal.Recurse(entry->GetRdOnlyPath());
639 const std::string &file_name) {
646 const std::string &link_name) {
653 const std::string &link_name) {
660 const std::string &link_name) {
667 const std::string &link_name) {
673 const std::string &link_name) {
680 const std::string &dir_name) {
687 const std::string &file_name) {
694 return entry->IsWhiteout();
698 const std::string &relative_parent_path,
const std::string &filename,
706 "Spooler callback for %s, digest %s, produced %lu chunks, retval %d",
714 SyncItemList::iterator itr;
736 item.relative_parent_path(),
742 item.relative_parent_path());
753 "Spooler callback for hardlink %s, digest %s, retval %d",
766 SyncItemList::iterator j, jend;
786 const std::string notice =
"Nested catalog at " + directory->GetUnionPath();
796 const std::string notice =
"Nested catalog at " + directory->GetUnionPath();
841 const char *action_label;
845 if (path.at(0) !=
'/') {
846 action_label =
"[x-catalog-add]";
848 action_label =
"[add]";
857 assert(
"Invalid print action.");
862 const char *action_label;
866 if (path.at(0) !=
'/') {
867 action_label =
"[x-catalog-rem]";
869 action_label =
"[rem]";
879 assert(
"Invalid print action.");
884 const char *action_label;
888 action_label =
"[mod]";
896 assert(
"Invalid print action.");
903 if ((entry->IsSymlink() || entry->IsSpecialFile()) && !
params_->
dry_run) {
904 assert(!entry->HasGraftMarker());
914 entry->relative_parent_path());
918 if (entry->IsValidGraft()) {
920 if (entry->IsChunkedGraft()) {
924 entry->relative_parent_path(),
925 *(entry->GetGraftChunks()));
931 entry->relative_parent_path());
938 "Encountered a grafted file (%s) with "
939 "invalid grafting information; check contents of .cvmfsgraft-*"
940 " file. Aborting publish.",
941 entry->GetRelativePath().c_str());
943 }
else if (entry->relative_parent_path().empty()
944 && entry->IsCatalogMarker()) {
957 if (entry->IsNew()) {
958 if (entry->IsSymlink()) {
973 entry->GetUnionPath().c_str());
980 if (entry->WasSymlink()) {
993 if (entry->IsBundleSpec()) {
995 "Illegal directory name: .cvmfsbundles (%s). "
996 ".cvmfsbundles is reserved for bundles specification files",
997 entry->GetUnionPath().c_str());
1003 assert(!entry->HasGraftMarker());
1012 entry->relative_parent_path());
1017 if (entry->HasCatalogMarker()
1030 const std::string directory_path = entry->GetRelativePath();
1048 const std::string directory_path = entry->GetRelativePath();
1063 if (entry->HasCatalogMarker()
1066 }
else if (!entry->HasCatalogMarker()
1079 for (HardlinkGroupMap::const_iterator i = hardlinks.begin(),
1080 iEnd = hardlinks.end();
1083 if (i->second.hardlinks.size() != i->second.master->GetUnionLinkcount()
1086 i->second.master->GetUnionPath().c_str());
1090 for (SyncItemList::const_iterator j = i->second.hardlinks.begin(),
1091 jEnd = i->second.hardlinks.end();
1095 i->second.master->GetUnionPath())
1096 +
"/" + j->second->filename();
1104 if (i->second.master->IsSymlink() || i->second.master->IsSpecialFile())
1117 for (SyncItemList::const_iterator i = group.
hardlinks.begin(),
1121 hardlinks.push_back(
1131 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,...)