diff --git a/atom b/atom index e1d0e9b..a863d88 100755 --- a/atom +++ b/atom @@ -520,6 +520,38 @@ getFiles() { echo } +updateMimes() { + Update mime_types action 1 <<<"action != 1" + for destination in ${!destinationskipmime[@]} + do + IFS='|' + for mime_type in ${destinationskipmime["$destination"]} + do + IFS="$oldIFS" + Update mime_types action 0 >/dev/null < <( + cat <<-EOWhere + destination_id ${destinationid["$destination"]} + mime_text LIKE ${mime_type//*/%} + EOWhere + ) + done + done + for destination in ${!destinationcopymime[@]} + do + IFS='|' + for mime_type in ${destinationcopymime["$destination"]} + do + IFS="$oldIFS" + Update mime_types action 2 >/dev/null < <( + cat <<-EOWhere + destination_id ${destinationid["$destination"]} + mime_text LIKE ${mime_type//*/%} + EOWhere + ) + done + done +} + removeObsoleteFiles() { Delete source_files <<-EOWhere last_seen < $scantime @@ -659,6 +691,8 @@ createDestinations getFiles +updateMimes + removeObsoleteFiles closeDatabase diff --git a/share/schema.sql b/share/schema.sql index 791d02f..6121b78 100644 --- a/share/schema.sql +++ b/share/schema.sql @@ -26,7 +26,8 @@ CREATE TABLE mime_types ( id INTEGER PRIMARY KEY, destination_id INTEGER, mime_text TEXT UNIQUE NOT NULL, - action INTEGER DEFAULT 1 + action INTEGER DEFAULT 1, + FOREIGN KEY (destination_id) REFERENCES destinations(id) ); CREATE INDEX sourcefiles_by_name ON source_files (filename,id);