force no longer tries to override protection against commit images when clones exist
This commit is contained in:
parent
fb02296f24
commit
b2a3ab8dfb
73
qq2clone
73
qq2clone
|
@ -783,9 +783,6 @@ $(unset sqlite3; command -v sqlite3) --batch --separator $'\n' \
|
|||
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
|
||||
#-----------------------------#
|
||||
|
||||
# This section includes only helper functions for functions that import or
|
||||
# modify templates
|
||||
|
||||
#=========================================================================#
|
||||
commit_image ()
|
||||
# DESCRIPTION: Commit changes from staging image(s) to template image(s)
|
||||
|
@ -794,43 +791,35 @@ commit_image ()
|
|||
# PARAMETERS: $@ from calling function
|
||||
#=========================================================================#
|
||||
{
|
||||
if (( ${#CL_MAP[@]} + ${#BAD_CL[@]} > 1)) && (($# < 3)); then
|
||||
echo "This template still has clones. If changes are committed,"
|
||||
echo "these clones may become corrupted. To avoid this,"
|
||||
echo "retrieve any information you need from these clones"
|
||||
echo "and then delete them. Aborting"
|
||||
echo
|
||||
echo "To continue anyway, append argument \"force\""
|
||||
if (( ${#CL_MAP[@]} + ${#BAD_CL[@]} > 1)); then
|
||||
echo "Cannot commit image while there are clones. Aborting." >&2
|
||||
exit "$E_args"
|
||||
fi
|
||||
|
||||
local disk check t d
|
||||
if (($# < 3)); then
|
||||
get_disk_devices_db
|
||||
while read -r disk; do
|
||||
while read -r t; do
|
||||
check="$(sqlite3 "select exists \
|
||||
(select * from CLONES where template='$t');")"
|
||||
((check)) || continue
|
||||
while read -r d; do
|
||||
if [[ "$d" == "$disk" ]]; then
|
||||
echo "Although this template has no clones, template"
|
||||
echo "$t does. These templates share disk:"
|
||||
echo
|
||||
echo " $disk"
|
||||
echo
|
||||
echo "If changes are committed, these clones may become"
|
||||
echo "corrupted. To avoid this, retrieve any information you"
|
||||
echo "need from these clones and then delete them. Aborting."
|
||||
echo
|
||||
echo "To continue anyway, append argument \"force\""
|
||||
exit "$E_args"
|
||||
fi >&2
|
||||
done < <(sqlite3 "select disks from TEMPLATES where name='$t';")
|
||||
done < <(sqlite3 "select name from TEMPLATES where \
|
||||
not name='${OPT[TEMPLATE]}';")
|
||||
done < <(read_pipe)
|
||||
fi
|
||||
|
||||
get_disk_devices_db
|
||||
while read -r disk; do
|
||||
while read -r t; do
|
||||
check="$(sqlite3 "select exists \
|
||||
(select * from CLONES where template='$t');")"
|
||||
((check)) || continue
|
||||
while read -r d; do
|
||||
if [[ "$d" == "$disk" ]]; then
|
||||
echo "Although this template has no clones, template"
|
||||
echo "$t does. These templates share disk:"
|
||||
echo
|
||||
echo " $disk"
|
||||
echo
|
||||
echo "If changes are committed, these clones may become"
|
||||
echo "corrupted. To avoid this, retrieve any information you"
|
||||
echo "need from these clones and then delete them. Aborting."
|
||||
exit "$E_args"
|
||||
fi >&2
|
||||
done < <(sqlite3 "select disks from TEMPLATES where name='$t';")
|
||||
done < <(sqlite3 "select name from TEMPLATES where \
|
||||
not name='${OPT[TEMPLATE]}';")
|
||||
done < <(read_pipe)
|
||||
|
||||
if (($# < 3)); then
|
||||
echo "This operation has the potential to corrupt your master template"
|
||||
|
@ -845,12 +834,12 @@ fi
|
|||
while read -r disk; do
|
||||
((OPT[QUIET])) || echo "Committing $disk..."
|
||||
output="$(qemu-img commit -d "$disk" 2>&1)" ||
|
||||
{ echo "$output" >&2; echo "Operation failed" >&2;
|
||||
exit "$E_unexpected"; }
|
||||
{ echo "$output"; echo "Operation failed";
|
||||
exit "$E_unexpected"; } >&2
|
||||
rm -f "$disk" &>/dev/null ||
|
||||
{ echo "Failed to delete old image. Permission issue? " >&2;
|
||||
echo "Process may not have completed succesfully" >&2;
|
||||
exit "$E_permission"; }
|
||||
{ echo "Failed to delete old image. Permission issue?";
|
||||
echo "Process may not have completed succesfully";
|
||||
exit "$E_permission"; } >&2
|
||||
done < <(sqlite3 "select disks from CLONES where id='0' and\
|
||||
template='${OPT[TEMPLATE]}';")
|
||||
delete_machine 0 0
|
||||
|
@ -1084,7 +1073,7 @@ check_rw ()
|
|||
# be read and written to. If file is a directory and a preceding
|
||||
# argument is '-r', check recursively
|
||||
# INPUT: A filepath (preferably fully qualified as a file could technically
|
||||
# be named '-r'
|
||||
# be named '-r')
|
||||
# OUTPUT: Error messages and exit codes as needed
|
||||
# PARAMETERS: $@: Filepaths to check
|
||||
#=========================================================================#
|
||||
|
|
Loading…
Reference in New Issue