comment lib/destinations/* (#LLM-assisted - Claude Code)

This commit is contained in:
Vincent Riquer 2026-03-13 17:20:38 +01:00
parent 6474bcab25
commit d0175fa03d
2 changed files with 42 additions and 0 deletions

View File

@ -1,7 +1,22 @@
#!/bin/bash #!/bin/bash
# Copyright © 2012-2026 ScriptFanix
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# A copy of the GNU General Public License v3 is includded in the LICENSE file
# at the root of the project.
createDestinations() { createDestinations() {
for destination in ${destinations[@]} for destination in ${destinations[@]}
do do
# Create destination directory if it doesn't exist yet
if ! [ -d "${destinationpath["$destination"]}" ] if ! [ -d "${destinationpath["$destination"]}" ]
then then
if ! mkdir -p "${destinationpath["$destination"]}" if ! mkdir -p "${destinationpath["$destination"]}"
@ -10,6 +25,8 @@ createDestinations() {
exit $EINVDEST exit $EINVDEST
fi fi
fi fi
# Ensure the destination has a DB record; store its numeric ID
# for later use
destinationid["$destination"]=$( destinationid["$destination"]=$(
InsertIfUnset destinations <<<"name $destination ${destinationenabled[\"$destination\"]}" InsertIfUnset destinations <<<"name $destination ${destinationenabled[\"$destination\"]}"
) )

View File

@ -1,12 +1,32 @@
#!/bin/bash #!/bin/bash
# Copyright © 2012-2026 ScriptFanix
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# A copy of the GNU General Public License v3 is includded in the LICENSE file
# at the root of the project.
updateMimes() { updateMimes() {
# Reset all mime_actions to action=1 (transcode) as the default
Update mime_actions action 1 <<<"action != 1" Update mime_actions action 1 <<<"action != 1"
# For each destination's skip patterns, set action=0 (exclude from
# processing)
# Multiple patterns are pipe-separated; split by setting IFS='|'
for destination in ${!destinationskipmime[@]} for destination in ${!destinationskipmime[@]}
do do
IFS='|' IFS='|'
for mime_type in ${destinationskipmime["$destination"]} for mime_type in ${destinationskipmime["$destination"]}
do do
IFS="$oldIFS" IFS="$oldIFS"
# Convert config wildcard '*' to SQL wildcard '%'
Update mime_type_actions action 0 >/dev/null < <( Update mime_type_actions action 0 >/dev/null < <(
cat <<-EOWhere cat <<-EOWhere
destination_id = ${destinationid["$destination"]} destination_id = ${destinationid["$destination"]}
@ -15,12 +35,17 @@ updateMimes() {
) )
done done
done done
# For each destination's copy-mime patterns, set action=2 (copy
# verbatim)
# Multiple patterns are pipe-separated; split by setting IFS='|'
for destination in ${!destinationcopymime[@]} for destination in ${!destinationcopymime[@]}
do do
IFS='|' IFS='|'
for mime_type in ${destinationcopymime["$destination"]} for mime_type in ${destinationcopymime["$destination"]}
do do
IFS="$oldIFS" IFS="$oldIFS"
# Convert config wildcard '*' to SQL wildcard '%'
Update mime_type_actions action 2 >/dev/null < <( Update mime_type_actions action 2 >/dev/null < <(
cat <<-EOWhere cat <<-EOWhere
destination_id = ${destinationid["$destination"]} destination_id = ${destinationid["$destination"]}