Skip to content

Commit 4a704b1

Browse files
committed
Attempt 1 to fix volDupCheck. With support for int/ext vols as well as a check if its excluded
1 parent ee92380 commit 4a704b1

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

src/pages/content/settings.php

+28-5
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,9 @@ class="fa fa-clock-o title"></i>Notifications and scheduling</span>
583583
$volumes = "<b>No volumes - container will NOT being backed up!</b>";
584584
} else {
585585
foreach ($volumes as $index => $volume) {
586-
$excluded = in_array($volume, $containerSetting['exclude']) ? ' - <abbr style="color: red; font-weight: bold;" title="Will not being backed up! See exclusions list below!">EXCLUDED!</abbr> ' : '';
587-
$volumes[$index] = '<span class="fa ' . (!ABHelper::isVolumeWithinAppdata($volume) ? 'fa-external-link' : 'fa-folder') . '"></span> <code style="cursor:pointer;" data-container="' . $container['Name'] . '" onclick="addVolumeToExclude(this);">' . $volume . '</code>' . $excluded . '<span style="display: none;" class="multiVolumeWarn"> - <a target="_blank" href="https://forums.unraid.net/topic/137710-plugin-appdatabackup/?do=findComment&comment=1250363">used in multiple containers!</a></span>';
586+
$excluded = in_array($volume, $containerSetting['exclude']) ? ' - <abbr style="color: red; font-weight: bold;" title="Will not being backed up! See exclusions list below!">EXCLUDED!</abbr> ' : false;
587+
$internalVolume = ABHelper::isVolumeWithinAppdata($volume);
588+
$volumes[$index] = '<span class="fa ' . (!$internalVolume ? 'fa-external-link' : 'fa-folder') . '"></span> <code style="cursor:pointer;" data-container="' . $container['Name'] . '" data-internal="' . ($internalVolume ? 'true' : 'false') . '" data-excluded="' . ($excluded ? 'true' : 'false') . '" onclick="addVolumeToExclude(this);">' . $volume . '</code>' . $excluded . '<span style="display: none;" class="multiVolumeWarn"> - <a target="_blank" href="https://forums.unraid.net/topic/137710-plugin-appdatabackup/?do=findComment&comment=1250363">used in multiple containers!</a></span>';
588589
}
589590
$volumes = implode('<br />', $volumes);
590591
}
@@ -1014,8 +1015,21 @@ function checkVolumesForDuplicates() {
10141015
let container = $(this).data('container');
10151016
let mapping = $(this).text();
10161017

1018+
if ($(this).data('excluded')) {
1019+
console.debug('Ignore ' + mapping + ': Excluded!');
1020+
return; // Ignore mapping, its excluded
1021+
}
1022+
1023+
if (!$(this).data('internal') && $('#' + container + '_backupExtVolumes').val() == 'no') {
1024+
console.debug('Ignore ' + mapping + ': Is external and external should not be backed up!');
1025+
return;
1026+
}
1027+
1028+
console.debug("CV: processing", container, mapping);
1029+
10171030
if (volumeMatrix.includes(mapping)) {
10181031
affectedMappings.push(mapping);
1032+
console.debug("CV: mapping affected!");
10191033
} else {
10201034
volumeMatrix.push(mapping);
10211035
}
@@ -1024,10 +1038,19 @@ function checkVolumesForDuplicates() {
10241038
console.debug("Volume dup check (affected/matrix): ", affectedMappings, volumeMatrix);
10251039

10261040
affectedMappings.forEach(function (element) {
1027-
let codeElems = $('code[data-container]:contains(' + element + ')');
1041+
let codeElems = $('code[data-container]').filter(function () {
1042+
return $(this).text() === element;
1043+
});
1044+
console.debug("Affected (filtered) code elems", codeElems);
10281045
codeElems.each(function () {
1029-
$('#containerMultiMappingIssue_' + $(this).data('container')).show();
1030-
$(this).next('.multiVolumeWarn').show();
1046+
console.debug("Affected Warn display: element/container:", element, $(this).data('container'));
1047+
let nextMultiWarnSpan = $(this).next('.multiVolumeWarn');
1048+
if (nextMultiWarnSpan.length) {
1049+
$('#containerMultiMappingIssue_' + $(this).data('container')).show();
1050+
nextMultiWarnSpan.show();
1051+
} else {
1052+
console.error("MultiWarnSpan not found!");
1053+
}
10311054
});
10321055
});
10331056
}

0 commit comments

Comments
 (0)