mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-22 08:26:19 +01:00
f5c4fcc250
E.g. replace `fs.Dir + filePath` with `path.Join(fs.Dir, filePath)` The fs.Dir is guaranteed to end with slash - see Init() functions. The filePath may start with slash. If it starts with slash, then `fs.Dir + filePath` constructs an incorrect path with double slashes. path.Join() properly substitutes duplicate slashes with a single slash in this case. While at it, also substitute incorrect usage of filepath.Join() with path.Join() for constructing paths to object storage systems, which expect forward slashes in paths. filepath.Join() substittues forward slashes with backslashes on Windows, so this may break creating or managing backups from Windows. This is a follow-up for 0399367be602b577baf6a872ca81bf0f99ba401b Updates https://github.com/VictoriaMetrics/VictoriaMetrics-enterprise/pull/719
68 lines
1.9 KiB
Go
68 lines
1.9 KiB
Go
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 {
|
|
// MustStop must be called when the RemoteFS is no longer needed.
|
|
MustStop()
|
|
|
|
// 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 {
|
|
// MustStop must be called when the RemoteFS is no longer needed.
|
|
MustStop()
|
|
|
|
// 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
|
|
|
|
// DeleteFile deletes filePath at RemoteFS.
|
|
//
|
|
// filePath must use / as directory delimiters.
|
|
DeleteFile(filePath string) error
|
|
|
|
// CreateFile creates filePath at RemoteFS and puts data into it.
|
|
//
|
|
// filePath must use / as directory delimiters.
|
|
CreateFile(filePath string, data []byte) error
|
|
|
|
// HasFile returns true if filePath exists at RemoteFS.
|
|
//
|
|
// filePath must use / as directory delimiters.
|
|
HasFile(filePath string) (bool, error)
|
|
|
|
// ReadFile returns file contents at the given filePath.
|
|
//
|
|
// filePath must use / as directory delimiters.
|
|
ReadFile(filePath string) ([]byte, error)
|
|
}
|