aboutsummaryrefslogtreecommitdiff
path: root/src/routes/api/image/list.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/api/image/list.zig')
-rw-r--r--src/routes/api/image/list.zig19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/routes/api/image/list.zig b/src/routes/api/image/list.zig
index d305276..5d2eace 100644
--- a/src/routes/api/image/list.zig
+++ b/src/routes/api/image/list.zig
@@ -7,6 +7,7 @@ pub const access = .users;
const ImageInfo = struct {
id: []const u8,
+ timestamp: ?i64,
};
const Result = struct {
@@ -16,13 +17,23 @@ const Result = struct {
pub fn get(ctx: *Context) !Result {
var images: std.ArrayList(ImageInfo) = .empty;
- const images_list = ctx.storage.images.list();
- defer images_list.deinit();
+ var images_list = ctx.storage.images.list();
+ defer images_list.unlock();
+
+ var locked = ctx.storage.images.first_by_timestamp();
+ defer locked.unlock();
+
+ var current = locked.value;
+
+ while (current) |c| {
+ const image = ctx.storage.images.items.items[c.index];
- for (images_list.images) |*image| {
try images.append(ctx.allocator, .{
- .id = image.id
+ .id = try ctx.allocator.dupe(u8, image.id),
+ .timestamp = image.timestamp,
});
+
+ current = c.next();
}
return .{