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_);
59 OpenCatalogManager(repo_path_, new_raii_temp_dir_->dir(),
60 new_root_hash_, download_manager_, &stats_new_);
62 if (!old_catalog_mgr_.IsValid()) {
67 if (!new_catalog_mgr_.IsValid()) {
76 template <
typename RoCatalogMgr>
83 template <
typename RoCatalogMgr>
85 const std::string& repo_path,
const std::string&
temp_dir,
88 RoCatalogMgr* mgr =
new RoCatalogMgr(root_hash, repo_path, temp_dir,
89 download_manager, stats,
true);
95 template <
typename RoCatalogMgr>
98 if (IsIgnoredPath(path)) {
99 assert(!IsReportablePath(path));
105 old_catalog_mgr_->Listing(path, &old_listing);
106 sort(old_listing.begin(), old_listing.end(),
IsSmaller);
116 unsigned length_after_truncate = old_path.
GetLength();
120 new_catalog_mgr_->Listing(path, &new_listing);
121 sort(new_listing.begin(), new_listing.end(),
IsSmaller);
124 unsigned i_from = 0, size_from = old_listing.size();
125 unsigned i_to = 0, size_to = new_listing.size();
126 while ((i_from < size_from) || (i_to < size_to)) {
132 "CatalogDiffTool - Entry %s in old catalog has linkcount 0. "
138 "CatalogDiffTool - Entry %s in new catalog has linkcount 0. "
144 while (old_entry.
IsHidden()) old_entry = old_listing[++i_from];
145 while (new_entry.
IsHidden()) new_entry = new_listing[++i_to];
147 old_path.
Truncate(length_after_truncate);
149 new_path.
Truncate(length_after_truncate);
154 new_catalog_mgr_->LookupXattrs(new_path, &xattrs);
159 if (IsReportablePath(new_path)) {
162 new_catalog_mgr_->ListFileChunks(new_path, new_entry.
hash_algorithm(),
165 ReportAddition(new_path, new_entry, xattrs, chunks);
171 }
else if (
IsSmaller(old_entry, new_entry)) {
176 if (IsReportablePath(old_path)) {
177 ReportRemoval(old_path, old_entry);
182 assert(old_path == new_path);
192 id_nested_from = old_catalog_mgr_->GetNestedCatalogHash(old_path);
193 id_nested_to = new_catalog_mgr_->GetNestedCatalogHash(new_path);
195 if (id_nested_from == id_nested_to)
continue;
198 if (IsReportablePath(old_path) &&
204 new_catalog_mgr_->ListFileChunks(new_path, new_entry.
hash_algorithm(),
208 ReportModification(old_path, old_entry, new_entry, xattrs, chunks);
209 if (!recurse)
continue;
226 #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,...)