2019-11-07 20:05:39 +01:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
)
|
|
|
|
|
|
|
|
// OriginFS is an interface for remote origin filesystem.
|
|
|
|
//
|
|
|
|
// This filesystem is used for performing server-side file copies
|
|
|
|
// instead of uploading data from local filesystem.
|
|
|
|
type OriginFS interface {
|
2020-10-09 14:31:39 +02:00
|
|
|
// MustStop must be called when the RemoteFS is no longer needed.
|
|
|
|
MustStop()
|
|
|
|
|
2019-11-07 20:05:39 +01:00
|
|
|
// String must return human-readable representation of OriginFS.
|
|
|
|
String() string
|
|
|
|
|
|
|
|
// ListParts must return all the parts for the OriginFS.
|
|
|
|
ListParts() ([]Part, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoteFS is a filesystem where backups are stored.
|
|
|
|
type RemoteFS interface {
|
2020-10-09 14:31:39 +02:00
|
|
|
// MustStop must be called when the RemoteFS is no longer needed.
|
|
|
|
MustStop()
|
|
|
|
|
2019-11-07 20:05:39 +01:00
|
|
|
// String must return human-readable representation of RemoteFS.
|
|
|
|
String() string
|
|
|
|
|
|
|
|
// ListParts must return all the parts for the RemoteFS.
|
|
|
|
ListParts() ([]Part, error)
|
|
|
|
|
|
|
|
// DeletePart must delete part p from RemoteFS.
|
|
|
|
DeletePart(p Part) error
|
|
|
|
|
|
|
|
// RemoveEmptyDirs must recursively remove empty directories in RemoteFS.
|
|
|
|
RemoveEmptyDirs() error
|
|
|
|
|
|
|
|
// CopyPart must copy part p from dstFS to RemoteFS.
|
|
|
|
CopyPart(dstFS OriginFS, p Part) error
|
|
|
|
|
|
|
|
// DownloadPart must download part p from RemoteFS to w.
|
|
|
|
DownloadPart(p Part, w io.Writer) error
|
|
|
|
|
|
|
|
// UploadPart must upload part p from r to RemoteFS.
|
|
|
|
UploadPart(p Part, r io.Reader) error
|
2020-01-09 14:24:26 +01:00
|
|
|
|
2023-12-04 09:21:29 +01:00
|
|
|
// DeleteFile deletes filePath at RemoteFS.
|
|
|
|
//
|
|
|
|
// filePath must use / as directory delimiters.
|
2020-01-09 14:24:26 +01:00
|
|
|
DeleteFile(filePath string) error
|
|
|
|
|
|
|
|
// CreateFile creates filePath at RemoteFS and puts data into it.
|
2023-12-04 09:21:29 +01:00
|
|
|
//
|
|
|
|
// filePath must use / as directory delimiters.
|
2020-01-09 14:24:26 +01:00
|
|
|
CreateFile(filePath string, data []byte) error
|
|
|
|
|
|
|
|
// HasFile returns true if filePath exists at RemoteFS.
|
2023-12-04 09:21:29 +01:00
|
|
|
//
|
|
|
|
// filePath must use / as directory delimiters.
|
2020-01-09 14:24:26 +01:00
|
|
|
HasFile(filePath string) (bool, error)
|
2023-08-14 02:17:12 +02:00
|
|
|
|
|
|
|
// ReadFile returns file contents at the given filePath.
|
2023-12-04 09:21:29 +01:00
|
|
|
//
|
|
|
|
// filePath must use / as directory delimiters.
|
2023-08-14 02:17:12 +02:00
|
|
|
ReadFile(filePath string) ([]byte, error)
|
2019-11-07 20:05:39 +01:00
|
|
|
}
|