...
|
...
|
@@ -275,20 +275,34 @@ function add_aircraft () {
|
275
|
275
|
for key in name revision date author; do
|
276
|
276
|
test -n "${ac_ass_array[$key]}" # exit if missing data (with the help of "set -e")
|
277
|
277
|
done
|
278
|
|
- sqlite_request "insert into recover_aircrafts (name, revision, date, author, hangar)
|
279
|
|
- values (
|
280
|
|
- '${ac_ass_array[name]}',
|
281
|
|
- ${ac_ass_array[revision]},
|
282
|
|
- ${ac_ass_array[date]},
|
283
|
|
- '${ac_ass_array[author]}',
|
284
|
|
- ${hangar[id]})"
|
|
278
|
+ local new_revision=$(sqlite_request "select revision from recover_aircrafts
|
|
279
|
+ where name = '${ac_ass_array[name]}'")
|
|
280
|
+ if test -z "${new_revision}"; then
|
|
281
|
+ sqlite_request "insert into recover_aircrafts (name, revision, date, author, hangar)
|
|
282
|
+ values (
|
|
283
|
+ '${ac_ass_array[name]}',
|
|
284
|
+ ${ac_ass_array[revision]},
|
|
285
|
+ ${ac_ass_array[date]},
|
|
286
|
+ '${ac_ass_array[author]}',
|
|
287
|
+ ${hangar[id]})"
|
|
288
|
+ elif test ${new_revision} -lt ${ac_ass_array[revision]//\"}; then
|
|
289
|
+ sqlite_request "update recover_aircrafts
|
|
290
|
+ set
|
|
291
|
+ revision = ${ac_ass_array[revision]},
|
|
292
|
+ date = ${ac_ass_array[date]},
|
|
293
|
+ author = '${ac_ass_array[author]}',
|
|
294
|
+ hangar = ${hangar[id]}
|
|
295
|
+ where name = '${ac_ass_array[name]}'"
|
|
296
|
+ fi
|
285
|
297
|
for key in name revision date author; do
|
286
|
298
|
ac_ass_array[$key]=''
|
287
|
299
|
done
|
288
|
300
|
}
|
289
|
301
|
|
290
|
302
|
function add_setxml_for_aircraft () {
|
291
|
|
- sqlite_request "insert into recover_setxml values ('$1', '${2/%-set.xml}')"
|
|
303
|
+ sqlite_request "insert into recover_setxml values ('$1', '${2/%-set.xml}')
|
|
304
|
+ on conflict (ac, sx) where ac = '$1' and sx = '${2/%-set.xml}'
|
|
305
|
+ do nothing"
|
292
|
306
|
}
|
293
|
307
|
|
294
|
308
|
function apply_revision () {
|
...
|
...
|
@@ -442,6 +456,8 @@ for h_id in $(sqlite_request "select id from hangars where active = 1"); do
|
442
|
456
|
ac text,
|
443
|
457
|
sx text)'
|
444
|
458
|
|
|
459
|
+ sqlite_request 'create unique index if not exists "index_recover_setxml" on recover_setxml (ac, sx)'
|
|
460
|
+
|
445
|
461
|
eval $(sqlite_request "select printf('hangar[id]=%i;hangar[source]=%s;', id, source)
|
446
|
462
|
from hangars
|
447
|
463
|
where id = '${h_id}'")
|
...
|
...
|
@@ -461,6 +477,7 @@ for h_id in $(sqlite_request "select id from hangars where active = 1"); do
|
461
|
477
|
if declare -f on_exit > /dev/null; then
|
462
|
478
|
on_exit
|
463
|
479
|
fi
|
|
480
|
+ sqlite_request "drop index 'index_recover_setxml'"
|
464
|
481
|
sqlite_request "drop table recover_aircrafts"
|
465
|
482
|
sqlite_request "drop table recover_setxml"
|
466
|
483
|
done
|