Commits

Anonymous committed d0cfd3d

Support for the "root" directory

The "root" directory is not included in the metadata supplied by the API so
we have to synthesise it ourselves.

Signed-off-by: Andy Bennett <andyjpb@knodium.com>

  • Participants
  • Parent commits c12a006

Comments (0)

Files changed (1)

 	  (from ,(metadata-cache-table))
 	  (where (and (or (= (col ,(metadata-cache-table) path-key) ,path-key)
 			  ,@(if recursive
-			      `((like (col ,(metadata-cache-table) path-key) ,(make-absolute-pathname path-key "%")))))
+			      `((like (col ,(metadata-cache-table) path-key) ,(string-append path-key "/%")))
+			      '()))
 		      ,(where-terms (metadata-cache-table))))))
 
 (define (select-directory-metadata path-key)
-  (let ((path-key (make-absolute-pathname path-key "%")))
+  (let ((path-key (string-append path-key "/%")))
     `(select (columns (col ,(metadata-cache-table)
 			   path-key revision rev thumb_exists bytes modified path
 			   is_dir icon root size is_deleted hash client_mtime))
 
 
 (define (canonicalise-path path)
- (string-chomp (string-downcase path) "/"))
+  (let ((path (string-chomp (string-downcase path) "/")))
+    (if (> (string-length path) 0)
+      (if (equal? #\/ (string-ref path 0))
+	path
+	(string-append "/" path))
+      "")))
 
 ; returns a list files
 ; if path is a file the list is of length 1
 (define (ls path #!optional directory)
   ; TODO: update-local-state! (conditional on some parameter flag)
   (let* ((path (canonicalise-path path))
-	 (path-meta (perform-read (select-metadata path)))
-	 )
+	 (path-meta (if (equal? "" path)
+		      '(((path-key . "")
+			 (revision . #f)
+			 (rev . #f)
+			 (thumb_exists . #f)
+			 (bytes . 0)
+			 (modified . #f)
+			 (path . "")
+			 (is_dir . 1)
+			 (icon . "folder_public")
+			 (root . "dropbox")
+			 (size . "0 bytes")
+			 (is_deleted) (hash) (client_mtime)))
+		      (perform-read (select-metadata path)))))
     (cond
       ((and directory
 	    (= 1 (length path-meta))