Megatest

Check-in [9833288949]
Login
Overview
Comment:Fixed remotediff example. Broken by unknown goof up.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.62
Files: files | file ages | folders
SHA1: 9833288949f3fbda311daa177e2d0e992040c17c
User & Date: mrwellan on 2016-11-16 10:12:10
Other Links: branch diff | manifest | tags
Context
2016-11-16
13:48
Try using md5sum instead of sha1. Much faster but what is the collison risk? check-in: 3e767a9aad user: mrwellan tags: v1.62, v1.6208
10:12
Fixed remotediff example. Broken by unknown goof up. check-in: 9833288949 user: mrwellan tags: v1.62
2016-11-11
10:59
Added deploy makefile check-in: 9c2e96a8c8 user: jmoon18 tags: v1.62
Changes

Modified remotediff-nmsg.scm from [c101aad63b] to [e39151f87a].

110
111
112
113
114
115
116
117
118

119
120
121




122
123
124
125
126
127
128
129


130
131
132
133
134
135
136
137
138
139
140
141
142
143












144

145

146

147

148
149

150










151
152
153
154
155
156
157
110
111
112
113
114
115
116


117
118
119

120
121
122
123
124
125
126
127
128
129
130

131
132
133
134
135
136
137
138
139
140






141
142
143
144
145
146
147
148
149
150
151
152
153
154

155
156
157

158


159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177







-
-
+


-
+
+
+
+







-
+
+








-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+

+
-
+

+
-
+
-
-
+

+
+
+
+
+
+
+
+
+
+







    (client-send-receive req "quit")
    (nn-close req)
    (exit)))

;; recieve and store the file data, note: this is effectively a *server*, not a client.
;;
(define (compare-directories path1 path2)
  (let ((last-print  (current-seconds))
        (p1dat       (make-hash-table))
  (let ((p1dat       (make-hash-table))
        (p2dat       (make-hash-table))
        (numdone     0) ;; increment when recieved a quit. exit when > 2
        (rep         (nn-socket 'rep)))
        (rep         (nn-socket 'rep))
        (p1len       (string-length path1))
        (p2len       (string-length path2))
        (both-seen   (make-hash-table)))
     (nn-bind    rep  
                 "tcp://*:5559")
                 ;; "ipc:///tmp/test-ipc")
     ;; start clients
     (thread-sleep! 0.1)
     (system (conc "./remotediff-nmsg " path1 " &"))
     (system (conc "./remotediff-nmsg " path2 " &"))
     (let loop ((msg-in (nn-recv rep)))
    (let loop ((msg-in (nn-recv rep))
               (last-print 0))
       (if (equal? msg-in "quit")
           (set! numdone (+ numdone 1)))
       (if (and (not (equal? msg-in "quit"))
                (< numdone 2))
           (let* ((parts (string-split msg-in))
                  (filen (car parts))
                  (finfo (cadr parts))
                  (isp1  (substring-index path1 filen 0)) ;; is this a path1?
                  (isp2  (substring-index path2 filen 0))) ;; is this a path2?
             (if isp1 
                 (if (hash-table-exists? p2dat 
                 (hash-table-set! p1dat filen finfo)
                 (hash-table-set! p2dat filen finfo))
             ;; (print "parts: " parts)
                 (isp2  (substring-index path2 filen 0)) ;; is this a path2?
                 (tpth  (substring filen (if isp1 p1len p2len) (string-length filen))))
            (hash-table-set! (if isp1 p1dat p2dat)
                             tpth
                             finfo)
            (if (and (hash-table-exists? p1dat tpth)
                     (hash-table-exists? p2dat tpth))
                (begin
                  (if (not (equal? (hash-table-ref p1dat tpth)
                                   (hash-table-ref p2dat tpth)))
                      (print "DIFF: " tpth))
                  (hash-table-set! both-seen tpth finfo)))
             (nn-send rep "done")
            (loop (nn-recv rep)
             (if (> last-print 15)
                  (if (> (- (current-seconds) last-print) 15)
                 (begin
                        (print "Processed " (hash-table-size p1dat) ", " (hash-table-size p2dat))
                   (set! last-print (current-seconds))
                        (current-seconds))
                   (print "Processed " num-files-1 ", " num-files-2)))
             (loop (nn-recv rep)))))
                      last-print)))))
     (print "p1: " (hash-table-size p1dat) " p2: " (hash-table-size p2dat))
    (hash-table-for-each
     p1dat
     (lambda (k v)
       (if (not (hash-table-exists? p2dat k))
           (print "REMOVED: " k))))
    (hash-table-for-each
     p2dat
     (lambda (k v)
       (if (not (hash-table-exists? p1dat k))
           (print "ADDED: " k))))
     (list p1dat p2dat)))

(if (< (length (argv)) 2)
    (begin
      (print "Usage: remotediff-nmsg file1 file2")
      (exit)))