mirror of
https://github.com/restic/restic.git
synced 2026-11-27 15:23:48 +00:00
Moves files
This commit is contained in:
1 parent
d1bd160b0a
commit
83d1a46526
284 files changed
No files matched your search
@@ -0,0 +1,62 @@
|
||||
package restic
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"restic/errors"
|
||||
)
|
||||
|
||||
// FileType is the type of a file in the backend.
|
||||
type FileType string
|
||||
|
||||
// These are the different data types a backend can store.
|
||||
const (
|
||||
DataFile FileType = "data"
|
||||
KeyFile = "key"
|
||||
LockFile = "lock"
|
||||
SnapshotFile = "snapshot"
|
||||
IndexFile = "index"
|
||||
ConfigFile = "config"
|
||||
)
|
||||
|
||||
// Handle is used to store and access data in a backend.
|
||||
type Handle struct {
|
||||
Type FileType
|
||||
Name string
|
||||
}
|
||||
|
||||
func (h Handle) String() string {
|
||||
name := h.Name
|
||||
if len(name) > 10 {
|
||||
name = name[:10]
|
||||
}
|
||||
return fmt.Sprintf("<%s/%s>", h.Type, name)
|
||||
}
|
||||
|
||||
// Valid returns an error if h is not valid.
|
||||
func (h Handle) Valid() error {
|
||||
if h.Type == "" {
|
||||
return errors.New("type is empty")
|
||||
}
|
||||
|
||||
switch h.Type {
|
||||
case DataFile:
|
||||
case KeyFile:
|
||||
case LockFile:
|
||||
case SnapshotFile:
|
||||
case IndexFile:
|
||||
case ConfigFile:
|
||||
default:
|
||||
return errors.Errorf("invalid Type %q", h.Type)
|
||||
}
|
||||
|
||||
if h.Type == ConfigFile {
|
||||
return nil
|
||||
}
|
||||
|
||||
if h.Name == "" {
|
||||
return errors.New("invalid Name")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user