Allow disabling destinations

This commit is contained in:
Vincent Riquer 2020-02-13 00:32:48 +01:00
parent dcf158a5a2
commit ed0191e450
8 changed files with 42 additions and 8 deletions

17
atom
View File

@ -13,6 +13,7 @@ EFMTINVPARM=49
# config structures # config structures
declare -A \ declare -A \
destinationenabled \
destinationascii \ destinationascii \
destinationchannels \ destinationchannels \
destinationfat32compat \ destinationfat32compat \
@ -330,6 +331,16 @@ fi
openDatabase openDatabase
for destination in "${!destinationpath[@]}"
do
if (( ${destinationenabled["$destination"]} ))
then
Update destinations enabled 1 <<<"name = $destination"
else
Update destinations enabled 0 <<<"name = $destination"
fi
done
createDestinations createDestinations
getFiles getFiles
@ -513,7 +524,8 @@ echo '
ON mime_type_actions.id = source_files.mime_type ON mime_type_actions.id = source_files.mime_type
INNER JOIN tags INNER JOIN tags
ON source_files.id = tags.source_file ON source_files.id = tags.source_file
WHERE CAST(destination_files.last_change AS TEXT) WHERE destinations.enabled = 1
AND CAST(destination_files.last_change AS TEXT)
<> CAST(source_files.last_change AS TEXT) <> CAST(source_files.last_change AS TEXT)
AND mime_type_actions.destination_id = destinations.id AND mime_type_actions.destination_id = destinations.id
AND mime_type_actions.action = 1;' >&3 AND mime_type_actions.action = 1;' >&3
@ -554,7 +566,8 @@ echo '
ON mime_type_actions.id = source_files.mime_type ON mime_type_actions.id = source_files.mime_type
INNER JOIN tags INNER JOIN tags
ON source_files.id = tags.source_file ON source_files.id = tags.source_file
WHERE CAST(destination_files.last_change AS TEXT) WHERE destinations.enabled = 1
AND CAST(destination_files.last_change AS TEXT)
<> CAST(source_files.last_change AS TEXT) <> CAST(source_files.last_change AS TEXT)
AND mime_type_actions.destination_id = destinations.id AND mime_type_actions.destination_id = destinations.id
AND mime_type_actions.action = 1 AND mime_type_actions.action = 1

View File

@ -1,6 +1,9 @@
#!/bin/bash #!/bin/bash
getConfigDestination() { getConfigDestination() {
case "$key" in case "$key" in
'enabled')
destinationenabled["$destination"]="$value"
;;
'path') 'path')
destinationpath["$destination"]="$value" destinationpath["$destination"]="$value"
;; ;;

View File

@ -26,6 +26,7 @@ printConfig() {
cat <<-EOF cat <<-EOF
$destination|Path|${destinationpath["$destination"]} $destination|Path|${destinationpath["$destination"]}
|Enabled|${destinationenabled["$destination"]}
|Format|${destinationformat["$destination"]} |Format|${destinationformat["$destination"]}
|Quality|${destinationquality["$destination"]} |Quality|${destinationquality["$destination"]}
EOF EOF

View File

@ -60,6 +60,9 @@ path $sourcepath
# Common parameters: # Common parameters:
# Mandatory parameters: # Mandatory parameters:
# * enabled: Whether or not to treat this destination (1=tue/0=false)
enabled 1
# * path: Where files will be written # * path: Where files will be written
path ${destinationpath["$destination"]} path ${destinationpath["$destination"]}

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
currentdbversion=2 currentdbversion=3
checkDatabaseVersion() { checkDatabaseVersion() {
local dbversion local dbversion
if dbversion=$(Select atom version <<<"\"1\" = 1") if dbversion=$(Select atom version <<<"\"1\" = 1")

View File

@ -0,0 +1,14 @@
#!/bin/bash
upgradedatabase_2_3() {
local data \
datas \
id \
destination
echo "Upgrading database to version 3... (backup is $database.bak_v2)"
cp "$database" "$database.bak_v2"
echo 'ALTER TABLE destinations ADD COLUMN enabled INTEGER DEFAULT 1;' >&3
Update destinations enabled 1 <<< "1 = 1"
Update atom version 3 <<<"1 = 1"
}

View File

@ -11,7 +11,7 @@ createDestinations() {
fi fi
fi fi
destinationid["$destination"]=$( destinationid["$destination"]=$(
InsertIfUnset destinations <<<"name $destination" InsertIfUnset destinations <<<"name $destination ${destinationenabled[\"$destination\"]}"
) )
done done
} }

View File

@ -5,10 +5,10 @@ progressSpin() {
(( ++count )) (( ++count ))
else else
case $(( ++count % 40 )) in case $(( ++count % 40 )) in
0) echo -ne $count '\b|' ;; 0) echo -n $'\b|' ;;
10) echo -ne $count '\b/' ;; 10) echo -n $'\b/' ;;
20) echo -en $count '\b-' ;; 20) echo -n $'\b-' ;;
30) echo -ne $count '\b\\' ;; 30) echo -n $'\b\\' ;;
*) ;; *) ;;
esac esac
fi fi