@@ -255,13 +255,13 @@ (db (datashare:open-db configdat))) (if (> space-avail 10000) ;; dumb heuristic (begin (create-directory targ-path #t) (datastore:set-stored-path db id targ-path) - (print "Running command: rsync -av " source-path " " targ-path) + (print "Running command: rsync -av " source-path "/ " targ-path "/") (let ((th1 (make-thread (lambda () - (let ((pid (process-run "rsync" (list "-av" source-path targ-path)))) + (let ((pid (process-run "rsync" (list "-av" (conc source-path "/") (conc targ-path "/"))))) (process-wait pid) (datastore:set-copied db id "yes") (sqlite3:finalize! db))) "Data copy"))) (thread-start! th1)) @@ -340,11 +340,11 @@ ;; ;; #:y 'mouse ;; ) )))) (define (datashare:publish-view configdat) - (pp (hash-table->alist configdat)) + ;; (pp (hash-table->alist configdat)) (let* ((areas (configf:get-section configdat "areas")) (label-size "70x") (areas-sel (iup:listbox #:expand "HORIZONTAL" #:dropdown "YES")) (version-tb (iup:textbox #:expand "HORIZONTAL")) ;; #:size "50x")) (areas-sel (iup:listbox #:expand "HORIZONTAL" #:dropdown "YES")) @@ -397,11 +397,11 @@ (top (iup:show fd #:modal? "YES"))) (iup:attribute-set! source-tb "VALUE" (iup:attribute fd "VALUE")) (iup:destroy! fd)))))) (print "areas") - (pp areas) + ;; (pp areas) (fold (lambda (areadat num) ;; (print "Adding num=" num ", areadat=" areadat) (iup:attribute-set! areas-sel (conc num) (car areadat)) (+ 1 num)) 1 areas) @@ -465,11 +465,11 @@ (iup:attribute-set! date-submitted "TITLE" (time->string (seconds->local-time (datastore:pkg-get-datetime record)))) (iup:attribute-set! comment "TITLE" (datastore:pkg-get-comment record)) (iup:attribute-set! quality "TITLE" (datastore:pkg-get-quality record)) (iup:attribute-set! copy-link "TITLE" (datastore:pkg-get-store_type record)) )) - (print "id=" id " path=" path " record=" record);; (tree:node->path obj id) " run-id: " run-id) + ;; (print "id=" id " path=" path " record=" record);; (tree:node->path obj id) " run-id: " run-id) )))) (tb2 (iup:treebox #:value 0 #:name "Installed" #:expand "YES" @@ -573,30 +573,52 @@ (iup:attribute-set! tabs "TABTITLE1" "Get") (iup:attribute-set! tabs "TABTITLE2" "Manage") ;; (iup:attribute-set! tabs "BGCOLOR" "190 190 190") tabs))) (iup:main-loop)) + +;;====================================================================== +;; MISC +;;====================================================================== + +(define (datastore:find name paths) + (if (null? paths) + #f + (let loop ((hed (car paths)) + (tal (cdr paths))) + (if (file-exists? (conc hed "/" name)) + hed + (if (null? tal) + #f + (loop (car tal)(cdr tal))))))) ;;====================================================================== ;; MAIN ;;====================================================================== -(define (datashare:load-config path) - (let* ((exename (pathname-file (car (argv)))) - (fname (conc path "/." exename ".config"))) +(define (datashare:load-config exe-dir exe-name) + (let* ((fname (conc exe-dir "/." exe-name ".config"))) (ini:property-separator-patt " * *") (ini:property-separator #\space) (if (file-exists? fname) ;; (ini:read-ini fname) (read-config fname #f #t) (make-hash-table)))) +;; ease debugging by loading ~/.dashboardrc - remove from production! +(let ((debugcontrolf (conc (get-environment-variable "HOME") "/.datasharerc"))) + (if (file-exists? debugcontrolf) + (load debugcontrolf))) + (define (main) (let* ((args (argv)) (prog (car args)) (rema (cdr args)) - (configdat (datashare:load-config (pathname-directory prog)))) + (exe-name (pathname-file (car (argv)))) + (exe-dir (or (pathname-directory prog) + (datastore:find exe-name (string-split (get-environment-variable "PATH") ":")))) + (configdat (datashare:load-config exe-dir exe-name))) (cond ((eq? (length rema) 1) (case (string->symbol (car rema)) ((help -h -help --h --help) (print datashare:help))