sync: Expose sync.Exists function
This commit is contained in:
parent
5cf4565573
commit
c5a059bd3b
8 changed files with 31 additions and 31 deletions
|
|
@ -26,8 +26,8 @@ type Importer interface {
|
|||
Init() error
|
||||
// sync tries to pull the latest modification of the underlying storage.
|
||||
Sync() error
|
||||
// exists checks if the given location exists from the Importer point of view.
|
||||
exists(filename string) bool
|
||||
// Exists checks if the given location exists from the Importer point of view.
|
||||
Exists(filename string) bool
|
||||
// toURL gets the full path/URL to the given file, the Importer will look internaly (used for debuging purpose).
|
||||
toURL(filename string) string
|
||||
// importFile imports the file at the given URI, inside the global FILES/ directory.
|
||||
|
|
@ -64,7 +64,7 @@ var GlobalImporter Importer
|
|||
|
||||
// GetFileSize returns the size.
|
||||
func GetFileSize(i Importer, URI string) (size int64, err error) {
|
||||
if i.exists(URI) {
|
||||
if i.Exists(URI) {
|
||||
if fi, err := i.stat(URI); err != nil {
|
||||
return 0, err
|
||||
} else {
|
||||
|
|
@ -73,7 +73,7 @@ func GetFileSize(i Importer, URI string) (size int64, err error) {
|
|||
}
|
||||
|
||||
dirname := path.Dir(URI)
|
||||
if i.exists(dirname) {
|
||||
if i.Exists(dirname) {
|
||||
filename := path.Base(URI)
|
||||
if files, err := i.listDir(dirname); err != nil {
|
||||
return size, err
|
||||
|
|
@ -104,7 +104,7 @@ func GetFileSize(i Importer, URI string) (size int64, err error) {
|
|||
// GetFile helps to manage huge file transfert by concatenating splitted (with split(1)) files.
|
||||
func GetFile(i Importer, URI string) (io.Reader, func(), error) {
|
||||
// Import file if it exists
|
||||
if i.exists(URI) {
|
||||
if i.Exists(URI) {
|
||||
fd, err := i.getFile(URI)
|
||||
return fd, func() {
|
||||
if fdc, ok := fd.(io.ReadCloser); ok {
|
||||
|
|
@ -115,7 +115,7 @@ func GetFile(i Importer, URI string) (io.Reader, func(), error) {
|
|||
|
||||
// Try to find file parts
|
||||
dirname := path.Dir(URI)
|
||||
if i.exists(dirname) {
|
||||
if i.Exists(dirname) {
|
||||
filename := path.Base(URI)
|
||||
if files, err := i.listDir(dirname); err != nil {
|
||||
return nil, nil, err
|
||||
|
|
|
|||
Reference in a new issue