mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 06:40:54 +03:00
22
vfs/vfs.go
22
vfs/vfs.go
@@ -27,8 +27,21 @@ var (
|
||||
validAzAccessTier = []string{"", "Archive", "Hot", "Cool"}
|
||||
// ErrStorageSizeUnavailable is returned if the storage backend does not support getting the size
|
||||
ErrStorageSizeUnavailable = errors.New("unable to get available size for this storage backend")
|
||||
// ErrVfsUnsupported defines the error for an unsupported VFS operation
|
||||
ErrVfsUnsupported = errors.New("not supported")
|
||||
credentialsDirPath string
|
||||
)
|
||||
|
||||
// SetCredentialsDirPath sets the credentials dir path
|
||||
func SetCredentialsDirPath(credentialsPath string) {
|
||||
credentialsDirPath = credentialsPath
|
||||
}
|
||||
|
||||
// GetCredentialsDirPath returns the credentials dir path
|
||||
func GetCredentialsDirPath() string {
|
||||
return credentialsDirPath
|
||||
}
|
||||
|
||||
// Fs defines the interface for filesystem backends
|
||||
type Fs interface {
|
||||
Name() string
|
||||
@@ -40,6 +53,7 @@ type Fs interface {
|
||||
Rename(source, target string) error
|
||||
Remove(name string, isDir bool) error
|
||||
Mkdir(name string) error
|
||||
MkdirAll(name string, uid int, gid int) error
|
||||
Symlink(source, target string) error
|
||||
Chown(name string, uid int, gid int) error
|
||||
Chmod(name string, mode os.FileMode) error
|
||||
@@ -79,9 +93,6 @@ type File interface {
|
||||
Truncate(size int64) error
|
||||
}
|
||||
|
||||
// ErrVfsUnsupported defines the error for an unsupported VFS operation
|
||||
var ErrVfsUnsupported = errors.New("Not supported")
|
||||
|
||||
// QuotaCheckResult defines the result for a quota check
|
||||
type QuotaCheckResult struct {
|
||||
HasSpace bool
|
||||
@@ -438,6 +449,11 @@ func IsLocalOrSFTPFs(fs Fs) bool {
|
||||
return IsLocalOsFs(fs) || IsSFTPFs(fs)
|
||||
}
|
||||
|
||||
// IsLocalOrCryptoFs returns true if fs is local or local encrypted
|
||||
func IsLocalOrCryptoFs(fs Fs) bool {
|
||||
return IsLocalOsFs(fs) || IsCryptOsFs(fs)
|
||||
}
|
||||
|
||||
// SetPathPermissions calls fs.Chown.
|
||||
// It does nothing for local filesystem on windows
|
||||
func SetPathPermissions(fs Fs, path string, uid int, gid int) {
|
||||
|
||||
Reference in New Issue
Block a user