Skip to content

Commit

Permalink
ua-tree: make code more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
sebsura authored and BareosBot committed Dec 12, 2023
1 parent 9a4c62e commit 3fed3ac
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions core/src/dird/ua_tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -379,27 +379,19 @@ static int SetExtract(UaContext* ua,
}
}
} else {
if (extract) {
uint64_t key = 0;
bool is_hardlinked = false;

if (node->hard_link) {
// Every hardlink is in hashtable, and it points to linked file.
key = (((uint64_t)node->JobId) << 32) + node->FileIndex;
is_hardlinked = true;
}

if (is_hardlinked) {
/* If we point to a hard linked file, find that file in hardlinks
* hashmap, and mark it to be restored as well. */
HL_ENTRY* entry = (HL_ENTRY*)tree->root->hardlinks.lookup(key);
if (entry && entry->node) {
n = entry->node;
// if this is our first time marking it, then add to the count
if (!n->extract) { count += 1; }
n->extract = true;
n->extract_dir = (n->type == TN_DIR || n->type == TN_DIR_NLS);
}
if (extract && node->hard_link) {
// Every hardlink is in hashtable, and it points to linked file.
uint64_t key = (((uint64_t)node->JobId) << 32) + node->FileIndex;

/* If we point to a hard linked file, find that file in hardlinks
* hashmap, and mark it to be restored as well. */
HL_ENTRY* entry = (HL_ENTRY*)tree->root->hardlinks.lookup(key);
if (entry && entry->node) {
n = entry->node;
// if this is our first time marking it, then add to the count
if (!n->extract) { count += 1; }
n->extract = true;
n->extract_dir = (n->type == TN_DIR || n->type == TN_DIR_NLS);
}
}
}
Expand Down

0 comments on commit 3fed3ac

Please sign in to comment.