-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgemdrive.go
66 lines (56 loc) · 2.11 KB
/
gemdrive.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
package gemdrive
import (
"fmt"
"io"
"time"
)
type Item struct {
Size int64 `json:"size,omitempty"`
ModTime string `json:"modTime,omitempty"`
Children map[string]*Item `json:"children,omitempty"`
IsExecutable bool `json:"isExecutable,omitempty"`
}
type RemoteGetRequest struct {
Source string `json:"source,omitempty"`
Destination string `json:"destination,omitempty"`
Size int64 `json:"size,omitempty"`
PreserveAttributes bool `json:"preserveAttributes,omitempty"`
SourceOffset int64 `json:"sourceOffset,omitempty"`
DestinationOffset int64 `json:"destinationOffset,omitempty"`
Overwrite bool `json:"overwrite,omitempty"`
Truncate bool `json:"truncate,omitempty"`
}
type Backend interface {
List(path string, maxDepth int) (*Item, error)
Read(path string, offset, length int64) (*Item, io.ReadCloser, error)
}
type WritableBackend interface {
MakeDir(path string, recursive bool) error
Write(path string, data io.Reader, offset, length int64, overwrite, truncate bool) error
SetAttributes(path string, modTime time.Time, isExecutable bool) error
Delete(path string, recursive bool) error
}
type ImageServer interface {
GetImage(path string, size int) (io.Reader, int64, error)
}
type Error struct {
HttpCode int
Message string
}
func (e *Error) Error() string {
return fmt.Sprintf("%d: %s", e.HttpCode, e.Message)
}
type Override struct {
ContentType string `json:"contentType"`
}
type Config struct {
DashboardDomain string `json:"dashboard_domain,omitempty"`
FsDomain string `json:"fs_domain,omitempty"`
Port int `json:"port,omitempty"`
Dirs []string `json:"dirs,omitempty"`
DataDir string `json:"dataDir,omitempty"`
CacheDir string `json:"cacheDir,omitempty"`
RcloneDir string `json:"rcloneDir,omitempty"`
DomainMap map[string]string `json:"domainMap,omitempty"`
Overrides map[string]*Override `json:"overrides",omitempty"`
}