Skip to content

Commit

Permalink
skip non existent volumes and de duplicate volume list
Browse files Browse the repository at this point in the history
  • Loading branch information
Commifreak committed Apr 27, 2023
1 parent e1e3a55 commit a1631c3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/include/ABHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,20 +429,27 @@ public static function getContainerVolumes($container) {
self::backupLog("This volume is empty (rootfs mapped??)! Ignoring.", self::LOGLEVEL_DEBUG);
continue;
}
if (!file_exists($hostPath)) {
self::backupLog("'$hostPath' does NOT exist! Please check your mappings! Skipping it for now.", self::LOGLEVEL_WARN);
continue;
}
if (in_array($hostPath, $abSettings->allowedSources)) {
self::backupLog("Removing container mapping \"$hostPath\" because it is a source path!");
continue;
}
$volumes[] = rtrim($hostPath, '/');
$volumes[] = $hostPath;
}

$volumes = array_unique($volumes); // Remove duplicate Array values => https://forums.unraid.net/topic/137710-plugin-appdatabackup/?do=findComment&comment=1256267

usort($volumes, function ($a, $b) {
return strlen($a) <=> strlen($b);
});
self::backupLog("usorted volumes: " . print_r($volumes, true), self::LOGLEVEL_DEBUG);

/**
* Check volumes against nesting
* Maybe someone has a better idea how to solve it efficiently?
*/
foreach ($volumes as $volume) {
foreach ($volumes as $key2 => $volume2) {
Expand Down

0 comments on commit a1631c3

Please sign in to comment.