Skip to content

Commit 310c77d

Browse files
committed
fix test
Signed-off-by: kerthcet <kerthcet@gmail.com>
1 parent ae87f7e commit 310c77d

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

sandd/src/snapshot/manager.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,6 @@ impl SnapshotManager {
302302
None => anyhow::bail!("Tag '{}' does not exist", tag),
303303
}
304304
}
305-
// Deduplicate: multiple tags may point to same snapshot
306-
ids.sort();
307-
ids.dedup();
308305
ids
309306
} else {
310307
// No filter: load all snapshots
@@ -329,8 +326,14 @@ impl SnapshotManager {
329326
snapshots.push(snapshot.into());
330327
}
331328

332-
// Sort by creation time (newest first)
333-
snapshots.sort_by(|a: &SnapshotInfo, b: &SnapshotInfo| b.created_at.cmp(&a.created_at));
329+
// Sort by creation time (newest first), then deduplicate by ID
330+
// Note: when filtering by tags, multiple tags may point to same snapshot
331+
snapshots.sort_by(|a: &SnapshotInfo, b: &SnapshotInfo| {
332+
b.created_at.cmp(&a.created_at).then_with(|| a.id.cmp(&b.id))
333+
});
334+
335+
// Deduplicate by ID (keep first occurrence = newest due to sort)
336+
snapshots.dedup_by(|a, b| a.id == b.id);
334337

335338
Ok(snapshots)
336339
}

0 commit comments

Comments
 (0)