5 #define __STDC_FORMAT_MACROS
36 AbstractSyncMediator::~AbstractSyncMediator() {}
41 : catalog_manager_(catalog_manager)
43 , handle_hardlinks_(false)
73 const bool ignore_case_setting =
false;
74 string relative_path = entry->GetRelativePath();
78 ignore_case_setting)) )
81 relative_path.c_str());
93 if (entry->IsDirectory()) {
99 if (entry->IsBundleSpec()) {
101 "Bundles is currently an experimental feature.");
103 if (!entry->IsRegularFile()) {
106 if (entry->HasHardlinks()) {
107 PANIC(
kLogStderr,
"Error: .cvmfsbundles file must not be a hard link");
110 std::string parent_path =
GetParentPath(entry->GetUnionPath());
113 " directory of the repository. Found in %s", parent_path.c_str());
116 std::string json_string;
118 int fd = open(entry->GetUnionPath().c_str(), O_RDONLY);
121 entry->GetUnionPath().c_str());
125 entry->GetUnionPath().c_str());
133 if (entry->IsRegularFile() || entry->IsSymlink()) {
140 }
else if (entry->IsGraftMarker()) {
148 if (entry->IsSpecialFile() && !entry->IsWhiteout()) {
151 "is a special file, ignoring.");
162 "' cannot be added. Unrecognized file type.");
172 if (entry->IsGraftMarker()) {
return;}
173 if (entry->IsDirectory()) {
179 if (entry->IsRegularFile() || entry->IsSymlink() || entry->IsSpecialFile()) {
190 if (entry->WasSymlink()) {
194 if (entry->IsSymlink()) {
199 dif += entry->GetScratchSize();
204 dif -= entry->GetRdOnlySize();
205 if (entry->IsSymlink()) {
210 dif += entry->GetScratchSize();
223 "' cannot be touched. Unrecognized file type.");
233 if (entry->WasDirectory()) {
238 if (entry->WasBundleSpec()) {
244 if (entry->WasRegularFile() || entry->WasSymlink() ||
245 entry->WasSpecialFile()) {
251 "' cannot be deleted. Unrecognized file type.");
299 "Waiting for upload of files before committing...");
331 i->master->GetUnionPath().c_str());
343 i->master->GetUnionPath().c_str());
374 unlink(empty_file.c_str());
390 uint64_t inode = entry->GetUnionInode();
392 inode, entry->GetUnionPath().c_str());
395 HardlinkGroupMap::iterator hardlink_group =
GetHardlinkMap().find(inode);
403 hardlink_group->second.AddHardlink(entry);
407 if (entry->IsNew()) {
422 if (entry->GetUnionLinkcount() < 2)
425 uint64_t inode = entry->GetUnionInode();
426 HardlinkGroupMap::iterator hl_group;
433 for (SyncItemList::const_iterator i = hl_group->second.hardlinks.begin(),
434 iEnd = hl_group->second.hardlinks.end(); i != iEnd; ++i)
436 if (*(i->second) == *entry) {
448 entry->GetUnionPath().c_str());
450 hl_group->second.AddHardlink(entry);
470 entry->GetUnionPath().c_str());
478 traversal.fn_new_character_dev =
483 traversal.Recurse(entry->GetUnionPath());
488 const string &file_name)
496 const string &file_name)
504 const string &parent_dir,
505 const string &file_name)
513 const string &parent_dir,
514 const string &file_name)
522 const string &file_name)
529 const string &file_name)
554 traversal.Recurse(entry->GetScratchPath());
559 const std::string &dir_name)
568 const std::string &file_name)
576 const std::string &file_name)
584 const std::string &file_name)
592 const std::string &file_name)
599 const std::string &file_name) {
606 const std::string &link_name)
615 const std::string &dir_name)
623 const std::string &dir_name)
634 const bool recurse =
false;
638 traversal.fn_new_dir_postfix =
645 traversal.Recurse(entry->GetRdOnlyPath());
653 const std::string &file_name)
661 const std::string &link_name)
669 const std::string &parent_dir,
670 const std::string &link_name)
678 const std::string &parent_dir,
679 const std::string &link_name)
687 const std::string &link_name)
694 const std::string &link_name)
702 const std::string &dir_name)
710 const std::string &file_name)
718 return entry->IsWhiteout();
722 const std::string &relative_parent_path,
const std::string &filename,
730 "Spooler callback for %s, digest %s, produced %lu chunks, retval %d",
740 SyncItemList::iterator itr;
760 item.CreateBasicCatalogDirent(),
762 item.relative_parent_path(),
766 item.CreateBasicCatalogDirent(),
768 item.relative_parent_path());
780 "Spooler callback for hardlink %s, digest %s, retval %d",
794 SyncItemList::iterator j, jend;
814 const std::string notice =
"Nested catalog at " + directory->GetUnionPath();
824 const std::string notice =
"Nested catalog at " + directory->GetUnionPath();
869 const char *action_label;
873 if (path.at(0) !=
'/') {
874 action_label =
"[x-catalog-add]";
876 action_label =
"[add]";
885 assert(
"Invalid print action.");
890 const char *action_label;
894 if (path.at(0) !=
'/') {
895 action_label =
"[x-catalog-rem]";
897 action_label =
"[rem]";
907 assert(
"Invalid print action.");
912 const char *action_label;
916 action_label =
"[mod]";
924 assert(
"Invalid print action.");
931 if ((entry->IsSymlink() || entry->IsSpecialFile()) && !
params_->
dry_run) {
932 assert(!entry->HasGraftMarker());
940 entry->relative_parent_path());
944 if (entry->IsValidGraft()) {
946 if (entry->IsChunkedGraft()) {
949 entry->relative_parent_path(), *(entry->GetGraftChunks()));
952 entry->CreateBasicCatalogDirent(),
955 entry->relative_parent_path());
962 "Encountered a grafted file (%s) with "
963 "invalid grafting information; check contents of .cvmfsgraft-*"
964 " file. Aborting publish.",
965 entry->GetRelativePath().c_str());
967 }
else if (entry->relative_parent_path().empty() &&
968 entry->IsCatalogMarker()) {
981 if (entry->IsNew()) {
982 if (entry->IsSymlink()) {
997 entry->GetUnionPath().c_str());
1004 if (entry->WasSymlink()) {
1017 if (entry->IsBundleSpec()) {
1019 ".cvmfsbundles is reserved for bundles specification files",
1020 entry->GetUnionPath().c_str());
1026 assert(!entry->HasGraftMarker());
1034 entry->relative_parent_path());
1039 if (entry->HasCatalogMarker() &&
1052 const std::string directory_path = entry->GetRelativePath();
1070 const std::string directory_path = entry->GetRelativePath();
1083 if (entry->HasCatalogMarker() &&
1086 }
else if (!entry->HasCatalogMarker() &&
1099 for (HardlinkGroupMap::const_iterator i = hardlinks.begin(),
1100 iEnd = hardlinks.end(); i != iEnd; ++i)
1102 if (i->second.hardlinks.size() != i->second.master->GetUnionLinkcount() &&
1105 i->second.master->GetUnionPath().c_str());
1109 for (SyncItemList::const_iterator j = i->second.hardlinks.begin(),
1110 jEnd = i->second.hardlinks.end(); j != jEnd; ++j)
1112 std::string changeset_notice =
1114 j->second->filename();
1122 if (i->second.master->IsSymlink() || i->second.master->IsSpecialFile())
1135 for (SyncItemList::const_iterator i = group.
hardlinks.begin(),
1136 iEnd = group.
hardlinks.end(); i != iEnd; ++i)
1138 hardlinks.push_back(i->second->CreateBasicCatalogDirent());
1148 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)
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,...)