Fix snapshot list to not download manifests

- Removed unnecessary manifest downloads from snapshot list command
- Removed blob size calculation from listing operation
- Removed COMPRESSED SIZE column from output since we're not calculating it
- This makes snapshot list much faster and avoids 404 errors for old snapshots
This commit is contained in:
Jeffrey Paul 2025-07-26 03:16:18 +02:00
parent 0cbb5aa0a6
commit c07d8eec0a

View File

@ -512,18 +512,17 @@ func (app *SnapshotApp) List(ctx context.Context, jsonOutput bool) error {
// Table output
w := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', 0)
if _, err := fmt.Fprintln(w, "SNAPSHOT ID\tTIMESTAMP\tCOMPRESSED SIZE"); err != nil {
if _, err := fmt.Fprintln(w, "SNAPSHOT ID\tTIMESTAMP"); err != nil {
return err
}
if _, err := fmt.Fprintln(w, "───────────\t─────────\t───────────────"); err != nil {
if _, err := fmt.Fprintln(w, "───────────\t─────────"); err != nil {
return err
}
for _, snap := range snapshots {
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\n",
if _, err := fmt.Fprintf(w, "%s\t%s\n",
snap.ID,
snap.Timestamp.Format("2006-01-02 15:04:05"),
formatBytes(snap.CompressedSize)); err != nil {
snap.Timestamp.Format("2006-01-02 15:04:05")); err != nil {
return err
}
}
@ -700,25 +699,8 @@ func (app *SnapshotApp) getSnapshots(ctx context.Context) ([]SnapshotInfo, error
}
}
// For each snapshot, download manifest and calculate total blob size
// Convert map to slice without downloading manifests
for _, snap := range snapshotMap {
manifest, err := app.downloadManifest(ctx, snap.ID)
if err != nil {
log.Warn("Failed to download manifest", "id", snap.ID, "error", err)
continue
}
// Calculate total size of referenced blobs
for _, blobHash := range manifest {
blobPath := fmt.Sprintf("blobs/%s/%s/%s", blobHash[:2], blobHash[2:4], blobHash)
info, err := app.S3Client.StatObject(ctx, blobPath)
if err != nil {
log.Warn("Failed to stat blob", "blob", blobHash, "error", err)
continue
}
snap.CompressedSize += info.Size
}
snapshots = append(snapshots, *snap)
}