fix: rename R2 object key prefix from live/ to hls/ for consistency
This commit is contained in:
1 parent
cca8d77325
commit
926d70dc3c
2 files changed
+9
-9
No files matched your search
@@ -124,7 +124,7 @@ func watchAndPublishSegments(ctx context.Context, hlsOutputDir string) {
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
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 {
|
||||
consecutiveFails++
|
||||
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
|
||||
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)
|
||||
}
|
||||
|
||||
// 2. Atomic copy to final key
|
||||
_, err := r2Client.CopyObject(context.TODO(), &s3.CopyObjectInput{
|
||||
Bucket: aws.String(bucket),
|
||||
CopySource: aws.String(bucket + "/live/playlist.m3u8.tmp"),
|
||||
Key: aws.String("live/playlist.m3u8"),
|
||||
CopySource: aws.String(bucket + "/hls/playlist.m3u8.tmp"),
|
||||
Key: aws.String("hls/playlist.m3u8"),
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("manifest atomic swap failed: %w", err)
|
||||
@@ -704,7 +704,7 @@ func syncLatestToR2(hlsDir string) error {
|
||||
}
|
||||
|
||||
for _, f := range files {
|
||||
key := "live/" + runID + "/" + filepath.Base(f)
|
||||
key := "hls/" + runID + "/" + filepath.Base(f)
|
||||
if err := SyncToR2(f, key); err != nil {
|
||||
fmt.Printf("Failed to sync %s: %v\n", f, err)
|
||||
} else {
|
||||
@@ -714,7 +714,7 @@ func syncLatestToR2(hlsDir string) error {
|
||||
|
||||
// Sync init segment to run-specific R2 key
|
||||
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
|
||||
}
|
||||
fmt.Println("Synced init.mp4 to R2")
|
||||
|
||||
@@ -495,15 +495,15 @@ func TestSyncToR2(t *testing.T) {
|
||||
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)
|
||||
}
|
||||
|
||||
if gotBucket != "linearvoid-media" {
|
||||
t.Fatalf("bucket = %q, want %q", gotBucket, "linearvoid-media")
|
||||
}
|
||||
if gotKey != "live/segment.m4s" {
|
||||
t.Fatalf("key = %q, want %q", gotKey, "live/segment.m4s")
|
||||
if gotKey != "hls/segment.m4s" {
|
||||
t.Fatalf("key = %q, want %q", gotKey, "hls/segment.m4s")
|
||||
}
|
||||
if string(gotBody) != "segment-bytes" {
|
||||
t.Fatalf("body = %q, want %q", string(gotBody), "segment-bytes")
|
||||
|
||||
Reference in new issue
Block a user