Modify the function which is used to ignore a path. (#112)

Modify the function which is used to ignore a path.
@ shouldn't be hardcoded.
Create 2 separate functions to ignore a specific path or prefix path.
In specific path, only exact paths are ignored.
In prefix path, any path starting with the specified string will be ignored.
e.g :
if specific path = @, only @ snapshot will be ignored.
if prefix path = @, all snapshots beginning with "@/..." will be ignored.
This commit is contained in:
Antynea
2020-10-06 23:19:41 +02:00
committed by GitHub
parent 6af193c47a
commit 0fe512776a
2 changed files with 18 additions and 10 deletions
+8 -2
View File
@@ -80,6 +80,8 @@ show_snap_found=${GRUB_BTRFS_SHOW_SNAPSHOTS_FOUND:-"true"}
show_total_snap_found=${GRUB_BTRFS_SHOW_TOTAL_SNAPSHOTS_FOUND:-"true"}
## Ignore specific path during run "grub-mkconfig"
ignore_specific_path=("${GRUB_BTRFS_IGNORE_SPECIFIC_PATH[@]}")
## Ignore prefix path during run "grub-mkconfig"
ignore_prefix_path=("${GRUB_BTRFS_IGNORE_PREFIX_PATH[@]}")
## Snapper's config name
snapper_config=${GRUB_BTRFS_SNAPPER_CONFIG:-"root"}
## Override boot partition detection
@@ -267,9 +269,13 @@ snapshot_list()
# ignore specific path during run "grub-mkconfig"
if [ ! -z "${ignore_specific_path}" ] ; then
[[ "${snap_path_name}" == "@" ]] && continue 2;
for isp in ${ignore_specific_path[@]} ; do
[[ "${snap_path_name}" == "${isp}" || "${snap_path_name}" == "${isp}"/* ]] && continue 2;
[[ "${snap_path_name}" == "${isp}" ]] && continue 2;
done
fi
if [ ! -z "${ignore_prefix_path}" ] ; then
for isp in ${ignore_prefix_path[@]} ; do
[[ "${snap_path_name}" == "${isp}"/* ]] && continue 2;
done
fi