added sftp client implementation

This commit is contained in:
ston1th 2022-04-02 20:05:07 +02:00
commit ce73f0472c
175 changed files with 28135 additions and 13 deletions

View file

@ -7,6 +7,7 @@ import (
"cachefs/pkg/provider/parse"
"context"
"errors"
"fmt"
stdfs "io/fs"
"net/http"
"os"
@ -36,11 +37,11 @@ func NewFS(quota int64, max int, src, dst, metadata string, log logr.Logger) (fs
}
srcfs, err := parse.FS(src)
if err != nil {
return
return nil, fmt.Errorf("srcfs: %w", err)
}
dstfs, err := parse.FS(dst)
if err != nil {
return
return nil, fmt.Errorf("dstfs: %w", err)
}
ctx, cancel := context.WithCancel(context.Background())
@ -57,11 +58,11 @@ func NewFS(quota int64, max int, src, dst, metadata string, log logr.Logger) (fs
fs.mh, err = NewMetadataHandler(ctx, fs, metadata, dst, log.WithName("metadata"))
if err != nil {
return
return nil, fmt.Errorf("metadata: %w", err)
}
fs.q, err = NewQuota(fs.mh.Size(), quota, fs, log.WithName("quota"))
if err != nil {
return
return nil, fmt.Errorf("quota: %w", err)
}
fs.ph = NewPreloadHandler(ctx, fs, max, log.WithName("preload"))
fs.sc = NewStatCache(ctx)
@ -235,5 +236,7 @@ func (fs *FS) CacheStatus(name string) int {
func (fs *FS) Close() {
fs.cancel()
fs.src.Close()
fs.dst.Close()
<-fs.done
}