summaryrefslogtreecommitdiff
path: root/workhorse/internal/upload/destination/filestore/filestore.go
blob: 6b2d8270b511fc8ac8176bdc0b89d720226532ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// The filestore package has a consumer specific to uploading to local disk storage.
package filestore

import (
	"context"
	"io"
	"time"
)

type LocalFile struct {
	File io.WriteCloser
}

func (lf *LocalFile) Consume(_ context.Context, r io.Reader, _ time.Time) (int64, error) {
	n, err := io.Copy(lf.File, r)
	errClose := lf.File.Close()
	if err == nil {
		err = errClose
	}
	return n, err
}

func (lf *LocalFile) ConsumeWithoutDelete(outerCtx context.Context, reader io.Reader, deadLine time.Time) (_ int64, err error) {
	return lf.Consume(outerCtx, reader, deadLine)
}