-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmirror.go
73 lines (60 loc) · 1.38 KB
/
mirror.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package mirror
import (
"context"
"io"
"time"
"github.com/apex/log"
)
type Storage interface {
StorageReader
StorageWriter
Exists(ctx context.Context, path string) bool
}
type StorageReader interface {
NewReader(ctx context.Context, path string) (io.ReadCloser, error)
}
type StorageWriter interface {
NewWriter(ctx context.Context, path string) io.WriteCloser
Delete(ctx context.Context, path string) error
}
type ReadOnlyStorage interface {
StorageReader
FindFiles(rootPath string, fileExt ...string) []FileInfo
}
type MetadataRepo interface {
MetadataRepoReader
MetadataRepoWriter
}
type MetadataRepoWriter interface {
Add(item RemotePhoto) error
Delete(id string) error
Persist(ctx context.Context) error
}
type MetadataRepoReader interface {
GetAll() []RemotePhoto
Exists(id string) (bool, error)
GetByDir(name string) ([]RemotePhoto, error)
GetByDirAndId(dir, id string) (RemotePhoto, error)
GetDirs() ([]string, error)
Reload(ctx context.Context) error
}
type Extractor interface {
Extract(ctx context.Context, logctx log.Interface, photos []FileInfo) []LocalPhoto
}
type FileInfo interface {
ID() string
FilePath() string
}
type RemotePhoto interface {
ID() string
ThumbID() string
Dir() string
}
type LocalPhoto interface {
RemotePhoto
FilePath() string
CreatedAt() time.Time
SetCreatedAt(t time.Time)
Thumbnail() []byte
NewJpgReader() (io.ReadCloser, error)
}