mirror of
https://github.com/get-drexa/drive.git
synced 2026-02-02 16:21:16 +00:00
fix: vfs list children not handling empty rows
This commit is contained in:
@@ -307,6 +307,7 @@ func (h *HTTPHandler) listDirectory(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
if cursor := c.Query("cursor"); cursor != "" {
|
if cursor := c.Query("cursor"); cursor != "" {
|
||||||
dc, err := decodeListChildrenCursor(cursor)
|
dc, err := decodeListChildrenCursor(cursor)
|
||||||
|
fmt.Printf("dc: %v\n", dc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "invalid cursor"})
|
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "invalid cursor"})
|
||||||
}
|
}
|
||||||
@@ -361,10 +362,17 @@ func (h *HTTPHandler) listDirectory(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cursor != nil {
|
||||||
|
return c.JSON(listDirectoryResponse{
|
||||||
|
Items: items,
|
||||||
|
NextCursor: encodeListChildrenCursor(cursor),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return c.JSON(listDirectoryResponse{
|
return c.JSON(listDirectoryResponse{
|
||||||
Items: items,
|
Items: items,
|
||||||
NextCursor: encodeListChildrenCursor(cursor),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// patchDirectory updates directory properties
|
// patchDirectory updates directory properties
|
||||||
@@ -663,7 +671,7 @@ func encodeListChildrenCursor(cursor *virtualfs.ListChildrenCursor) string {
|
|||||||
d = 1
|
d = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
s := fmt.Sprintf("%d:%d:%s", by, d, cursor.Node.ID)
|
s := fmt.Sprintf("%d:%d:%s", by, d, cursor.Node.PublicID)
|
||||||
return base64.URLEncoding.EncodeToString([]byte(s))
|
return base64.URLEncoding.EncodeToString([]byte(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -254,6 +254,10 @@ func (vfs *VirtualFS) ListChildren(ctx context.Context, db bun.IDB, node *Node,
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return make([]*Node, 0), nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
c := &ListChildrenCursor{
|
c := &ListChildrenCursor{
|
||||||
Node: nodes[len(nodes)-1],
|
Node: nodes[len(nodes)-1],
|
||||||
OrderBy: opts.OrderBy,
|
OrderBy: opts.OrderBy,
|
||||||
|
|||||||
Reference in New Issue
Block a user