fix: do not cache m3u8 files

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov
2025-07-01 23:51:15 +07:00
parent 181aa99c43
commit a68925459a
4 changed files with 15 additions and 4 deletions
+4 -1
View File
@@ -84,7 +84,7 @@ func getObjectKeyFromPath(s string) string {
}
// PutFile uploads file to the datalake
func (d *DatalakeStorage) PutFile(ctx context.Context, fileName string) error {
func (d *DatalakeStorage) PutFile(ctx context.Context, fileName string, options PutOptions) error {
// #nosec
file, err := os.Open(fileName)
if err != nil {
@@ -127,6 +127,9 @@ func (d *DatalakeStorage) PutFile(ctx context.Context, fileName string) error {
req.Header.SetMethod(fasthttp.MethodPost)
req.Header.Add("Authorization", "Bearer "+d.token)
req.Header.SetContentType(writer.FormDataContentType())
if options.NoCache {
req.Header.Add("Cache-Control", "max-age=0, must-revalidate")
}
req.SetBody(body.Bytes())
if err := d.client.Do(req, res); err != nil {
+1 -1
View File
@@ -84,7 +84,7 @@ func (u *S3Storage) DeleteFile(ctx context.Context, fileName string) error {
}
// PutFile uploads file to the s3 storage
func (u *S3Storage) PutFile(ctx context.Context, fileName string) error {
func (u *S3Storage) PutFile(ctx context.Context, fileName string, options PutOptions) error {
var _, objectKey = filepath.Split(fileName)
var logger = u.logger.With(zap.String("upload", u.bucketName), zap.String("fileName", fileName))
+6 -1
View File
@@ -37,9 +37,14 @@ type BlobInfo struct {
ETag string
}
// PutOptions represents options for the PutFile operation
type PutOptions struct {
NoCache bool
}
// Storage represents file-based storage
type Storage interface {
PutFile(ctx context.Context, fileName string) error
PutFile(ctx context.Context, fileName string, options PutOptions) error
DeleteFile(ctx context.Context, fileName string) error
GetFile(ctx context.Context, fileName, destination string) error
StatFile(ctx context.Context, fileName string) (*BlobInfo, error)
+4 -1
View File
@@ -316,7 +316,10 @@ func (u *uploaderImpl) uploadAndDelete(f string) {
for attempt := range u.options.RetryCount {
logger = logger.With(zap.Int("attempt", attempt))
var putCtx, putCancel = context.WithTimeout(u.uploadCtx, u.options.Timeout)
var err = u.storage.PutFile(putCtx, f)
var putOptions = storage.PutOptions{
NoCache: u.shouldDeleteOnStop(f),
}
var err = u.storage.PutFile(putCtx, f, putOptions)
putCancel()
if err != nil {