@@ -175,11 +175,11 @@ ;; newdb) ;; (stack-pop! (dbr:subdb-dbstack subdb))) ;; (db:open-db subdb run-id))) ;; ) -(define (db:get-db dbstruct run-id) +#;(define (db:get-db dbstruct run-id) (let* ((subdb (dbfile:get-subdb dbstruct run-id)) (dbdat (dbfile:get-dbdat dbstruct run-id))) (if (dbr:dbdat? dbdat) dbdat (dbfile:open-db *dbstruct-dbs* #f db:initialize-main-db) @@ -1077,17 +1077,16 @@ (define (db:all-db-sync dbstruct) - (db:open-db dbstruct #f) - (let* ((data-synced 0) ;; count of changed records + (let* ((dbdat (db:open-db dbstruct #f)) + (data-synced 0) ;; count of changed records (tmp-area (common:get-db-tmp-area)) (dbfiles (glob (conc tmp-area"/.db/*.db"))) (sync-durations (make-hash-table)) - (no-sync-db (db:open-no-sync-db)) - ) + (no-sync-db (db:open-no-sync-db))) (for-each (lambda (file) (debug:print-info 3 *default-log-port* "file: " file) (let* ((fname (conc (pathname-file file) ".db")) (fulln (conc *toppath*"/.db/"fname)) @@ -1116,28 +1115,21 @@ (if do-cp (let* ((start-time (current-milliseconds)) (fname (pathname-file file)) (runid (if (string= fname "main") #f (string->number fname))) ) - (debug:print-info 3 *default-log-port* "db:all-db-sync: fname: " fname", delta: " (- time1 time2) " seconds") - + (debug:print-info 3 *default-log-port* "db:all-db-sync: fname: " + fname", delta: " (- time1 time2) " seconds") (db:lock-and-delta-sync no-sync-db dbstruct fname runid) - (hash-table-set! sync-durations (conc fname".db") (- (current-milliseconds) start-time))) + (hash-table-set! sync-durations (conc fname".db") + (- (current-milliseconds) start-time))) (debug:print-info 3 *default-log-port* "skipping sync. " file " is up to date") - ) - ) - ) + ))) dbfiles - ) - ) - #t -) - - - - - + ) + (if dbdat (dbfile:add-dbdat dbstruct #f dbdat))) + #t) ;; options: ;; ;; 'killservers - kills all servers ;; 'dejunk - removes junk records @@ -1147,19 +1139,15 @@ ;; 'closeall - close all opened dbs ;; 'schema - attempt to apply schema changes ;; run-ids: '(1 2 3 ...) or #f (for all) ;; (define (db:multi-db-sync dbstruct . options) - - (db:open-db dbstruct #f) - - (let* ((data-synced 0) ;; count of changed records + (let* ((dbdat (db:open-db dbstruct #f)) + (data-synced 0) ;; count of changed records (tmp-area (common:get-db-tmp-area)) (dbfiles (glob (conc tmp-area"/.db/*.db"))) - (sync-durations (make-hash-table)) - ) - + (sync-durations (make-hash-table))) (for-each (lambda (file) (debug:print-info 0 *default-log-port* "file: " file) (let* ((fname (conc (pathname-file file) ".db")) (fulln (conc *toppath*"/.db/"fname)) @@ -1267,10 +1255,11 @@ ) ) (stack-push! (dbr:subdb-dbstack subdb) main-tmpdb)) options))) (hash-table-values (dbr:dbstruct-subdbs dbstruct))) + (if dbdat (dbfile:add-dbdat dbstruct #f dbdat)) data-synced) ) ;; Sync all changed db's ;;