Showing 1 changed files with 9 additions and 7 deletions
+9 -7
analyse-votes-AN
... ...
@@ -412,15 +412,17 @@ EOcontent
412 412
 function save_database () {
413 413
     test -n "$result" -a -d "/dev/shm/$result" && rm -fr "/dev/shm/$result"
414 414
     test -n "$database" -a -n "$in_ram_database" || return
415
-    test -r "$in_ram_database" || return
416
-    if test -r "$database" && md5sum $in_ram_database | sed "s,$in_ram_database,$database," | md5sum --status -c -; then
417
-        rm -f $in_ram_database
415
+    if test -r "$database" && sqldiff=$(sqldiff $in_ram_database $database) && test -z "$sqldiff"; then
416
+        echo "pas de modification"
418 417
     elif test -w "$database"; then
419
-        mv -f $in_ram_database "$database"
420
-    elif ! test -e "$database"; then
421
-        mv $in_ram_database "$database"
418
+        rm -f "$database"
419
+        sqlite_request '.dump' | sqlite3 "$database"
420
+        echo "base de données $database mise à jour"
421
+    elif test ! -e "$database" -a -w ${database%/*}; then
422
+        sqlite_request '.dump' | sqlite3 "$database"
423
+        echo "base de données $database créée"
422 424
     else
423
-        rm -f $in_ram_database
425
+        echo "je ne peux rien faire avec $database !"
424 426
     fi
425 427
 }
426 428