Commit 5d06f28b authored by Dave Griffiths's avatar Dave Griffiths

sync dirtify fixes

parent 8dd940f8
......@@ -243,8 +243,9 @@
(define (start-sync-files)
(http-request
(string-append "file-list")
(string-append "http://192.168.2.1:8889/")
(string-append url "fn=file-list")
(lambda (file-list)
(sync-files file-list))))
;; spit all dirty entities to server
(define (spit db table entities)
......@@ -361,7 +362,7 @@
(when ((not (find id server-ids)))
(msg "can't find " id " in server data, marking dirty")
;; mark those not present as dirty for next spit cycle
(update-entity-dirty db table id)))
(update-entity-dirtify db table id)))
ids)))
;; repeatedly read version and request updates
......
......@@ -47,12 +47,11 @@
(clean-entity-values db table (entity-id-from-unique db table unique-id)) )
;; for when remote entities don't exist for whatever reason
(define (update-entity-dirty db table unique-id)
(define (update-entity-dirtify db table unique-id)
(db-exec
db (string-append "update " table "_entity set dirty=? where unique_id = ?")
1 unique-id)
;; simpler path than cleaning - should use the same as this???
(dirty-all-values db table (entity-id-from-unique db table unique-id)))
(dirtify-entity-values db table (entity-id-from-unique db table unique-id)) )
(define (have-dirty? db table)
(not (zero?
......
......@@ -64,6 +64,18 @@
(clean-value db table entity-id (list (ktv-key kt) (ktv-type kt))))
(get-attribute-ids/types db table entity-type))))))
(define (dirtify-entity-values db table entity-id)
;;(msg "clean-entity-values")
(let* ((entity-type (get-entity-type db table entity-id)))
(cond
((null? entity-type)
(msg "dirtify-entity-values: entity" entity-id "not found!") '())
(else
(for-each
(lambda (kt)
(dirtify-value db table entity-id (list (ktv-key kt) (ktv-type kt))))
(get-attribute-ids/types db table entity-type))))))
;; update an entity, via a (possibly partial) list of key/value pairs
;; if dirty is not true, this is coming from a sync
(define (update-entity-values db table entity-id ktvlist dirty)
......
......@@ -122,8 +122,7 @@
" set dirty=0 where entity_id = ? and attribute_id = ?")
entity-id (ktv-key kt)))
;; simpler path than cleaning - should use the same as this???
(define (dirty-all-values db table entity-id)
(define (dirtify-value db table entity-id kt)
(db-exec db (string-append "update " table "_value_" (ktv-type kt)
" set dirty=1 where entity_id = ?")
entity-id))
" set dirty=1 where entity_id = ? and attribute_id = ?")
entity-id (ktv-key kt)))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment