Skip to content

Commit 043bd97

Browse files
committed
Limit loop iterations in listAssetsWithPagination for demo purposes
1 parent 69ba7c6 commit 043bd97

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

example/example.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,15 @@ func bulkDeleteAssets(cld *cloudinary.Cloudinary, ctx context.Context, publicIDs
215215
// List all assets in pages of up to maxResults, using cursor-based pagination.
216216
func listAssetsWithPagination(cld *cloudinary.Cloudinary, ctx context.Context, maxResults int) {
217217
nextCursor := ""
218+
loopCount := 0
219+
maxLoops := 4 // Limit the number of loops for demo purposes
218220

219221
for {
222+
if loopCount >= maxLoops {
223+
log.Println("Reached maximum number of loops for demo purposes.")
224+
break
225+
}
226+
220227
page, err := cld.Admin.Assets(
221228
ctx,
222229
admin.AssetsParams{MaxResults: maxResults, NextCursor: nextCursor},
@@ -233,5 +240,6 @@ func listAssetsWithPagination(cld *cloudinary.Cloudinary, ctx context.Context, m
233240
break // no more assets
234241
}
235242
nextCursor = page.NextCursor
243+
loopCount++
236244
}
237245
}

0 commit comments

Comments
 (0)