Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions exist-core/src/main/java/org/exist/backup/Restore.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public void restore(final DBBroker broker, @Nullable final Txn transaction, fina
// count all files
long totalNrOfFiles = 0;
for (BackupDescriptor backupDescriptor : descriptors) {
if (!isInsideAnotherDescriptor(backupDescriptor, descriptors))
totalNrOfFiles += backupDescriptor.getNumberOfFiles();
}

Expand Down Expand Up @@ -131,6 +132,23 @@ public void restore(final DBBroker broker, @Nullable final Txn transaction, fina
}
}
}

private boolean isInsideAnotherDescriptor(final BackupDescriptor descriptor, final Deque<BackupDescriptor> descriptors) {
final String pathToCheck = descriptor.getSymbolicPath();
for (final BackupDescriptor otherDescriptor : descriptors) {
if (otherDescriptor == (descriptor)) {
continue;
}
final String otherPathDescriptorPath = otherDescriptor.getSymbolicPath();
if(otherPathDescriptorPath.endsWith(BackupDescriptor.COLLECTION_DESCRIPTOR)) {
final String outerFolder = otherPathDescriptorPath.substring(0, otherPathDescriptorPath.length() - BackupDescriptor.COLLECTION_DESCRIPTOR.length());
if (pathToCheck.startsWith(outerFolder)) {
return true;
}
}
}
return false;
}

private Deque<BackupDescriptor> getBackupDescriptors(Path contents) throws IOException {
final Deque<BackupDescriptor> descriptors = new ArrayDeque<>();
Expand Down
Loading