fix: rename R2 object key prefix from live/ to hls/ for consistency
CI / test (push) Successful in 1m37s
CI / docker (push) Successful in 48s

This commit is contained in:
zwitschi committed 2026-08-11 17:21:53 +02:00
1 parent cca8d77325
commit 926d70dc3c
2 files changed
+9 -9

No files matched your search

+6 -6
View File
@@ -124,7 +124,7 @@ func watchAndPublishSegments(ctx context.Context, hlsOutputDir string) {
time.Sleep(500 * time.Millisecond) time.Sleep(500 * time.Millisecond)
segSequence++ segSequence++
lastSegmentSeq = segSequence lastSegmentSeq = segSequence
key := "live/" + runID + "/" + filepath.Base(event.Name) key := "hls/" + runID + "/" + filepath.Base(event.Name)
if err := SyncToR2(event.Name, key); err != nil { if err := SyncToR2(event.Name, key); err != nil {
consecutiveFails++ consecutiveFails++
fmt.Printf("Failed to sync segment %s: %v\n", event.Name, err) fmt.Printf("Failed to sync segment %s: %v\n", event.Name, err)
@@ -153,15 +153,15 @@ func publishManifest(localManifestPath string) error {
} }
// 1. Upload to temp key // 1. Upload to temp key
if err := SyncToR2(localManifestPath, "live/playlist.m3u8.tmp"); err != nil { if err := SyncToR2(localManifestPath, "hls/playlist.m3u8.tmp"); err != nil {
return fmt.Errorf("temp manifest upload failed: %w", err) return fmt.Errorf("temp manifest upload failed: %w", err)
} }
// 2. Atomic copy to final key // 2. Atomic copy to final key
_, err := r2Client.CopyObject(context.TODO(), &s3.CopyObjectInput{ _, err := r2Client.CopyObject(context.TODO(), &s3.CopyObjectInput{
Bucket: aws.String(bucket), Bucket: aws.String(bucket),
CopySource: aws.String(bucket + "/live/playlist.m3u8.tmp"), CopySource: aws.String(bucket + "/hls/playlist.m3u8.tmp"),
Key: aws.String("live/playlist.m3u8"), Key: aws.String("hls/playlist.m3u8"),
}) })
if err != nil { if err != nil {
return fmt.Errorf("manifest atomic swap failed: %w", err) return fmt.Errorf("manifest atomic swap failed: %w", err)
@@ -704,7 +704,7 @@ func syncLatestToR2(hlsDir string) error {
} }
for _, f := range files { for _, f := range files {
key := "live/" + runID + "/" + filepath.Base(f) key := "hls/" + runID + "/" + filepath.Base(f)
if err := SyncToR2(f, key); err != nil { if err := SyncToR2(f, key); err != nil {
fmt.Printf("Failed to sync %s: %v\n", f, err) fmt.Printf("Failed to sync %s: %v\n", f, err)
} else { } else {
@@ -714,7 +714,7 @@ func syncLatestToR2(hlsDir string) error {
// Sync init segment to run-specific R2 key // Sync init segment to run-specific R2 key
initPath := filepath.Join(hlsDir, "init.mp4") initPath := filepath.Join(hlsDir, "init.mp4")
if err := SyncToR2(initPath, "live/"+runID+"/init.mp4"); err != nil { if err := SyncToR2(initPath, "hls/"+runID+"/init.mp4"); err != nil {
return err return err
} }
fmt.Println("Synced init.mp4 to R2") fmt.Println("Synced init.mp4 to R2")
+3 -3
View File
@@ -495,15 +495,15 @@ func TestSyncToR2(t *testing.T) {
return &s3.PutObjectOutput{}, nil return &s3.PutObjectOutput{}, nil
} }
if err := SyncToR2(localPath, "live/segment.m4s"); err != nil { if err := SyncToR2(localPath, "hls/segment.m4s"); err != nil {
t.Fatalf("SyncToR2 error: %v", err) t.Fatalf("SyncToR2 error: %v", err)
} }
if gotBucket != "linearvoid-media" { if gotBucket != "linearvoid-media" {
t.Fatalf("bucket = %q, want %q", gotBucket, "linearvoid-media") t.Fatalf("bucket = %q, want %q", gotBucket, "linearvoid-media")
} }
if gotKey != "live/segment.m4s" { if gotKey != "hls/segment.m4s" {
t.Fatalf("key = %q, want %q", gotKey, "live/segment.m4s") t.Fatalf("key = %q, want %q", gotKey, "hls/segment.m4s")
} }
if string(gotBody) != "segment-bytes" { if string(gotBody) != "segment-bytes" {
t.Fatalf("body = %q, want %q", string(gotBody), "segment-bytes") t.Fatalf("body = %q, want %q", string(gotBody), "segment-bytes")