admin/sync: add stat method to importer

This commit is contained in:
nemunaire 2018-01-07 22:21:13 +01:00
parent 57758cd018
commit db9077a85c
3 changed files with 10 additions and 0 deletions

View File

@ -23,6 +23,7 @@ type Importer interface {
importFile(URI string, next func(string, string) (interface{}, error)) (interface{}, error) importFile(URI string, next func(string, string) (interface{}, error)) (interface{}, error)
getFile(filename string, writer *bufio.Writer) error getFile(filename string, writer *bufio.Writer) error
listDir(filename string) ([]string, error) listDir(filename string) ([]string, error)
stat(filename string) (os.FileInfo, error)
} }
var GlobalImporter Importer var GlobalImporter Importer

View File

@ -5,6 +5,7 @@ import (
"errors" "errors"
"net/http" "net/http"
"net/url" "net/url"
"os"
"path" "path"
"strings" "strings"
@ -95,3 +96,7 @@ func (i CloudImporter) listDir(filename string) ([]string, error) {
return res, nil return res, nil
} }
} }
func (i CloudImporter) stat(filename string) (os.FileInfo, error) {
return gowebdav.NewClient(i.baseDAV.String(), i.username, i.password).Stat(strings.Replace(url.PathEscape(filename), "%2F", "/", -1))
}

View File

@ -70,3 +70,7 @@ func (i LocalImporter) listDir(filename string) ([]string, error) {
return res, nil return res, nil
} }
} }
func (i LocalImporter) stat(filename string) (os.FileInfo, error) {
return os.Stat(path.Join(i.Base, filename))
}