mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-06 14:20:55 +03:00
refactor metadata support
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -38,11 +39,12 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
dirMimeType = "inode/directory"
|
||||
s3fsName = "S3Fs"
|
||||
gcsfsName = "GCSFs"
|
||||
azBlobFsName = "AzureBlobFs"
|
||||
preResumeTimeout = 90 * time.Second
|
||||
dirMimeType = "inode/directory"
|
||||
s3fsName = "S3Fs"
|
||||
gcsfsName = "GCSFs"
|
||||
azBlobFsName = "AzureBlobFs"
|
||||
lastModifiedField = "sftpgo_last_modified"
|
||||
preResumeTimeout = 90 * time.Second
|
||||
// ListerBatchSize defines the default limit for DirLister implementations
|
||||
ListerBatchSize = 1000
|
||||
)
|
||||
@@ -1080,6 +1082,31 @@ func IsUploadResumeSupported(fs Fs, size int64) bool {
|
||||
return fs.IsConditionalUploadResumeSupported(size)
|
||||
}
|
||||
|
||||
func getLastModified(metadata map[string]string) int64 {
|
||||
if val, ok := metadata[lastModifiedField]; ok {
|
||||
lastModified, err := strconv.ParseInt(val, 10, 64)
|
||||
if err == nil {
|
||||
return lastModified
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func getAzureLastModified(metadata map[string]*string) int64 {
|
||||
for k, v := range metadata {
|
||||
if strings.ToLower(k) == lastModifiedField {
|
||||
if val := util.GetStringFromPointer(v); val != "" {
|
||||
lastModified, err := strconv.ParseInt(val, 10, 64)
|
||||
if err == nil {
|
||||
return lastModified
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func validateOSFsConfig(config *sdk.OSFsConfig) error {
|
||||
if config.ReadBufferSize < 0 || config.ReadBufferSize > 10 {
|
||||
return fmt.Errorf("invalid read buffer size must be between 0 and 10 MB")
|
||||
|
||||
Reference in New Issue
Block a user