5 #ifndef CVMFS_CATALOG_DIFF_TOOL_IMPL_H_
6 #define CVMFS_CATALOG_DIFF_TOOL_IMPL_H_
22 entry_list->push_back(empty_entry);
26 assert(!entry_list->empty());
29 entry_list->push_back(last_entry);
39 if (a_is_last || b_is_first)
return false;
40 if (a_is_first)
return !b_is_first;
41 if (b_is_last)
return !a_is_last;
45 template <
typename RoCatalogMgr>
54 OpenCatalogManager(repo_path_, old_raii_temp_dir_->dir(),
55 old_root_hash_, download_manager_, &stats_old_,
60 OpenCatalogManager(repo_path_, new_raii_temp_dir_->dir(),
61 new_root_hash_, download_manager_, &stats_new_,
64 if (!old_catalog_mgr_.IsValid()) {
69 if (!new_catalog_mgr_.IsValid()) {
78 template <
typename RoCatalogMgr>
85 template <
typename RoCatalogMgr>
87 const std::string& repo_path,
const std::string&
temp_dir,
90 RoCatalogMgr* mgr =
new RoCatalogMgr(root_hash, repo_path, temp_dir,
91 download_manager, stats,
true,
98 template <
typename RoCatalogMgr>
101 if (IsIgnoredPath(path)) {
102 assert(!IsReportablePath(path));
108 old_catalog_mgr_->Listing(path, &old_listing);
109 sort(old_listing.begin(), old_listing.end(),
IsSmaller);
119 unsigned length_after_truncate = old_path.
GetLength();
123 new_catalog_mgr_->Listing(path, &new_listing);
124 sort(new_listing.begin(), new_listing.end(),
IsSmaller);
127 unsigned i_from = 0, size_from = old_listing.size();
128 unsigned i_to = 0, size_to = new_listing.size();
129 while ((i_from < size_from) || (i_to < size_to)) {
135 "CatalogDiffTool - Entry %s in old catalog has linkcount 0. "
141 "CatalogDiffTool - Entry %s in new catalog has linkcount 0. "
147 while (old_entry.
IsHidden()) old_entry = old_listing[++i_from];
148 while (new_entry.
IsHidden()) new_entry = new_listing[++i_to];
150 old_path.
Truncate(length_after_truncate);
152 new_path.
Truncate(length_after_truncate);
157 new_catalog_mgr_->LookupXattrs(new_path, &xattrs);
162 if (IsReportablePath(new_path)) {
165 new_catalog_mgr_->ListFileChunks(new_path, new_entry.
hash_algorithm(),
168 ReportAddition(new_path, new_entry, xattrs, chunks);
174 }
else if (
IsSmaller(old_entry, new_entry)) {
179 if (IsReportablePath(old_path)) {
180 ReportRemoval(old_path, old_entry);
185 assert(old_path == new_path);
195 id_nested_from = old_catalog_mgr_->GetNestedCatalogHash(old_path);
196 id_nested_to = new_catalog_mgr_->GetNestedCatalogHash(new_path);
198 if (id_nested_from == id_nested_to)
continue;
201 if (IsReportablePath(old_path) &&
207 new_catalog_mgr_->ListFileChunks(new_path, new_entry.
hash_algorithm(),
211 ReportModification(old_path, old_entry, new_entry, xattrs, chunks);
212 if (!recurse)
continue;
229 #endif // CVMFS_CATALOG_DIFF_TOOL_IMPL_H_
uint32_t linkcount() const
Differences CompareTo(const DirectoryEntry &other) const
SharedPtr< string > temp_dir
void set_inode(const inode_t inode)
bool IsChunkedFile() const
void Truncate(unsigned new_length)
assert((mem||(size==0))&&"Out Of Memory")
bool IsNestedCatalogMountpoint() const
std::vector< DirectoryEntry > DirectoryEntryList
static RaiiTempDir * Create(const std::string &prefix)
static const inode_t kInvalidInode
void Append(const char *chars, const unsigned length)
shash::Algorithms hash_algorithm() const
unsigned GetLength() const
const char * c_str() const
const char * GetChars() const
static const unsigned int kIdentical
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)