forked from simplesurance/baur
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutputfile.go
54 lines (44 loc) · 1.09 KB
/
outputfile.go
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package baur
import (
"github.com/simplesurance/baur/v1/internal/digest"
"github.com/simplesurance/baur/v1/internal/fs"
)
// OutputFile is a file created by a task run.
type OutputFile struct {
*File
name string
// UploadsS3 can be nil
UploadsS3 *UploadInfoS3
// UploadsFilecopy can be nil
UploadsFilecopy *UploadInfoFileCopy
}
func NewOutputFile(name, absPath string, s3upload *UploadInfoS3, filecopyUpload *UploadInfoFileCopy) *OutputFile {
return &OutputFile{
name: name,
File: &File{AbsPath: absPath},
UploadsS3: s3upload,
UploadsFilecopy: filecopyUpload,
}
}
func (f *OutputFile) String() string {
return "file: " + f.name
}
func (f *OutputFile) Name() string {
return f.name
}
func (f *OutputFile) Type() OutputType {
return FileOutput
}
func (f *OutputFile) Digest() (*digest.Digest, error) {
return f.File.Digest()
}
func (f *OutputFile) Exists() (bool, error) {
return fs.FileExists(f.AbsPath), nil
}
func (f *OutputFile) Size() (uint64, error) {
size, err := fs.FileSize(f.AbsPath)
if err != nil {
return 0, err
}
return uint64(size), nil
}