diff --git a/localstorage/currentstore.go b/localstorage/currentstore.go index e078576a..8a582d66 100644 --- a/localstorage/currentstore.go +++ b/localstorage/currentstore.go @@ -22,10 +22,6 @@ var ( checkedTempDir string ) -func Objects() *LocalStorage { - return objects -} - func InitStorage(cfg *config.Configuration) error { if len(cfg.LocalGitStorageDir()) == 0 || len(cfg.LocalGitDir()) == 0 { return notInRepoErr diff --git a/tq/adapterbase.go b/tq/adapterbase.go index db461737..bfcf9a68 100644 --- a/tq/adapterbase.go +++ b/tq/adapterbase.go @@ -7,6 +7,7 @@ import ( "strings" "sync" + "github.com/git-lfs/git-lfs/fs" "github.com/git-lfs/git-lfs/lfsapi" "github.com/rubyist/tracerx" ) @@ -15,6 +16,7 @@ import ( // process transfers with N workers handling an oid each, and which wait for // authentication to succeed on one worker before proceeding type adapterBase struct { + fs *fs.Filesystem name string direction Direction transferImpl transferImplementation @@ -49,8 +51,9 @@ type transferImplementation interface { DoTransfer(ctx interface{}, t *Transfer, cb ProgressCallback, authOkFunc func()) error } -func newAdapterBase(name string, dir Direction, ti transferImplementation) *adapterBase { +func newAdapterBase(f *fs.Filesystem, name string, dir Direction, ti transferImplementation) *adapterBase { return &adapterBase{ + fs: f, name: name, direction: dir, transferImpl: ti, diff --git a/tq/basic_download.go b/tq/basic_download.go index 9de568cf..96001663 100644 --- a/tq/basic_download.go +++ b/tq/basic_download.go @@ -10,7 +10,6 @@ import ( "strconv" "github.com/git-lfs/git-lfs/errors" - "github.com/git-lfs/git-lfs/localstorage" "github.com/git-lfs/git-lfs/tools" "github.com/rubyist/tracerx" ) @@ -28,7 +27,7 @@ func (a *basicDownloadAdapter) tempDir() string { // Must be dedicated to this adapter as deleted by ClearTempStorage // Also make local to this repo not global, and separate to localstorage temp, // which gets cleared at the end of every invocation - d := filepath.Join(localstorage.Objects().RootDir, "incomplete") + d := filepath.Join(a.fs.LFSStorageDir, "incomplete") if err := os.MkdirAll(d, 0755); err != nil { return os.TempDir() } @@ -222,7 +221,7 @@ func configureBasicDownloadAdapter(m *Manifest) { m.RegisterNewAdapterFunc(BasicAdapterName, Download, func(name string, dir Direction) Adapter { switch dir { case Download: - bd := &basicDownloadAdapter{newAdapterBase(name, dir, nil)} + bd := &basicDownloadAdapter{newAdapterBase(m.fs, name, dir, nil)} // self implements impl bd.transferImpl = bd return bd diff --git a/tq/basic_upload.go b/tq/basic_upload.go index eb8bb49e..a0582bb1 100644 --- a/tq/basic_upload.go +++ b/tq/basic_upload.go @@ -161,7 +161,7 @@ func configureBasicUploadAdapter(m *Manifest) { m.RegisterNewAdapterFunc(BasicAdapterName, Upload, func(name string, dir Direction) Adapter { switch dir { case Upload: - bu := &basicUploadAdapter{newAdapterBase(name, dir, nil)} + bu := &basicUploadAdapter{newAdapterBase(m.fs, name, dir, nil)} // self implements impl bu.transferImpl = bu return bu diff --git a/tq/custom.go b/tq/custom.go index 3a6af272..a98c4505 100644 --- a/tq/custom.go +++ b/tq/custom.go @@ -12,6 +12,7 @@ import ( "time" "github.com/git-lfs/git-lfs/errors" + "github.com/git-lfs/git-lfs/fs" "github.com/git-lfs/git-lfs/tools" "github.com/git-lfs/git-lfs/subprocess" @@ -124,7 +125,6 @@ func (a *customAdapter) ClearTempStorage() error { } func (a *customAdapter) WorkerStarting(workerNum int) (interface{}, error) { - // Start a process per worker // If concurrent = false we have already dialled back workers to 1 a.Trace("xfer: starting up custom transfer process %q for worker %d", a.name, workerNum) @@ -202,7 +202,6 @@ func (a *customAdapter) readResponse(ctx *customAdapterWorkerContext) (*customAd // exchangeMessage sends a message to a process and reads a response if resp != nil // Only fatal errors to communicate return an error, errors may be embedded in reply func (a *customAdapter) exchangeMessage(ctx *customAdapterWorkerContext, req interface{}) (*customAdapterResponseMessage, error) { - err := a.sendMessage(ctx, req) if err != nil { return nil, err @@ -341,8 +340,8 @@ func (a *customAdapter) DoTransfer(ctx interface{}, t *Transfer, cb ProgressCall return nil } -func newCustomAdapter(name string, dir Direction, path, args string, concurrent, standalone bool) *customAdapter { - c := &customAdapter{newAdapterBase(name, dir, nil), path, args, concurrent, 3, standalone} +func newCustomAdapter(f *fs.Filesystem, name string, dir Direction, path, args string, concurrent, standalone bool) *customAdapter { + c := &customAdapter{newAdapterBase(f, name, dir, nil), path, args, concurrent, 3, standalone} // self implements impl c.transferImpl = c return c @@ -372,7 +371,7 @@ func configureCustomAdapters(git Env, m *Manifest) { // Separate closure for each since we need to capture vars above newfunc := func(name string, dir Direction) Adapter { standalone := m.standaloneTransferAgent != "" - return newCustomAdapter(name, dir, path, args, concurrent, standalone) + return newCustomAdapter(m.fs, name, dir, path, args, concurrent, standalone) } if direction == "download" || direction == "both" { diff --git a/tq/tus_upload.go b/tq/tus_upload.go index 63196e1e..76084aac 100644 --- a/tq/tus_upload.go +++ b/tq/tus_upload.go @@ -165,7 +165,7 @@ func configureTusAdapter(m *Manifest) { m.RegisterNewAdapterFunc(TusAdapterName, Upload, func(name string, dir Direction) Adapter { switch dir { case Upload: - bu := &tusUploadAdapter{newAdapterBase(name, dir, nil)} + bu := &tusUploadAdapter{newAdapterBase(m.fs, name, dir, nil)} // self implements impl bu.transferImpl = bu return bu