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);
34 const bool a_is_first =
37 const bool b_is_first =
41 if (a_is_last || b_is_first)
50 template<
typename RoCatalogMgr>
58 old_catalog_mgr_ = OpenCatalogManager(repo_path_, old_raii_temp_dir_->dir(),
59 old_root_hash_, download_manager_,
60 &stats_old_, cache_dir_);
63 new_catalog_mgr_ = OpenCatalogManager(repo_path_, new_raii_temp_dir_->dir(),
64 new_root_hash_, download_manager_,
65 &stats_new_, cache_dir_);
67 if (!old_catalog_mgr_.IsValid()) {
72 if (!new_catalog_mgr_.IsValid()) {
81 template<
typename RoCatalogMgr>
88 template<
typename RoCatalogMgr>
90 const std::string &repo_path,
const std::string &
temp_dir,
93 RoCatalogMgr *mgr =
new RoCatalogMgr(
94 root_hash, repo_path, temp_dir, download_manager, stats,
true, cache_dir);
100 template<
typename RoCatalogMgr>
103 if (IsIgnoredPath(path)) {
104 assert(!IsReportablePath(path));
113 old_catalog_mgr_->Listing(path, &old_listing);
114 sort(old_listing.begin(), old_listing.end(),
IsSmaller);
124 const unsigned length_after_truncate = old_path.
GetLength();
128 new_catalog_mgr_->Listing(path, &new_listing);
129 sort(new_listing.begin(), new_listing.end(),
IsSmaller);
132 unsigned i_from = 0, size_from = old_listing.size();
133 unsigned i_to = 0, size_to = new_listing.size();
134 while ((i_from < size_from) || (i_to < size_to)) {
140 "CatalogDiffTool - Entry %s in old catalog has linkcount 0. "
146 "CatalogDiffTool - Entry %s in new catalog has linkcount 0. "
153 old_entry = old_listing[++i_from];
155 new_entry = new_listing[++i_to];
157 old_path.
Truncate(length_after_truncate);
159 new_path.
Truncate(length_after_truncate);
164 new_catalog_mgr_->LookupXattrs(new_path, &xattrs);
170 if (IsReportablePath(new_path)) {
173 new_catalog_mgr_->ListFileChunks(new_path, new_entry.
hash_algorithm(),
176 recurse &= ReportAddition(new_path, new_entry, xattrs, chunks);
182 }
else if (
IsSmaller(old_entry, new_entry)) {
187 if (IsReportablePath(old_path)) {
188 ReportRemoval(old_path, old_entry);
193 assert(old_path == new_path);
203 id_nested_from = old_catalog_mgr_->GetNestedCatalogHash(old_path);
204 id_nested_to = new_catalog_mgr_->GetNestedCatalogHash(new_path);
206 if (id_nested_from == id_nested_to)
210 if (IsReportablePath(old_path)
216 new_catalog_mgr_->ListFileChunks(new_path, new_entry.
hash_algorithm(),
220 ReportModification(old_path, old_entry, new_entry, xattrs, chunks);
231 #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
std::string ToString() 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,...)