Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 0 additions & 159 deletions libs/sync/repofiles/repofiles.go

This file was deleted.

88 changes: 0 additions & 88 deletions libs/sync/repofiles/repofiles_test.go

This file was deleted.

23 changes: 13 additions & 10 deletions libs/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"fmt"
"time"

"github.com/databricks/cli/libs/filer"
"github.com/databricks/cli/libs/git"
"github.com/databricks/cli/libs/log"
"github.com/databricks/cli/libs/sync/repofiles"
"github.com/databricks/databricks-sdk-go"
)

Expand All @@ -29,9 +29,9 @@ type SyncOptions struct {
type Sync struct {
*SyncOptions

fileSet *git.FileSet
snapshot *Snapshot
repoFiles *repofiles.RepoFiles
fileSet *git.FileSet
snapshot *Snapshot
filer filer.Filer

// Synchronization progress events are sent to this event notifier.
notifier EventNotifier
Expand Down Expand Up @@ -77,16 +77,19 @@ func New(ctx context.Context, opts SyncOptions) (*Sync, error) {
}
}

repoFiles := repofiles.Create(opts.RemotePath, opts.LocalPath, opts.WorkspaceClient)
filer, err := filer.NewWorkspaceFilesClient(opts.WorkspaceClient, opts.RemotePath)
if err != nil {
return nil, err
}

return &Sync{
SyncOptions: &opts,

fileSet: fileSet,
snapshot: snapshot,
repoFiles: repoFiles,
notifier: &NopNotifier{},
seq: 0,
fileSet: fileSet,
snapshot: snapshot,
filer: filer,
notifier: &NopNotifier{},
seq: 0,
}, nil
}

Expand Down
19 changes: 16 additions & 3 deletions libs/sync/watchdog.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ package sync

import (
"context"
"errors"
"io/fs"
"os"
"path/filepath"

"github.com/databricks/cli/libs/filer"
"golang.org/x/sync/errgroup"
)

Expand All @@ -21,8 +26,8 @@ func (s *Sync) applyDelete(ctx context.Context, group *errgroup.Group, remoteNam

group.Go(func() error {
s.notifyProgress(ctx, EventActionDelete, remoteName, 0.0)
err := s.repoFiles.DeleteFile(ctx, remoteName)
if err != nil {
err := s.filer.Delete(ctx, remoteName)
if err != nil && !errors.Is(err, fs.ErrNotExist) {
return err
}
s.notifyProgress(ctx, EventActionDelete, remoteName, 1.0)
Expand All @@ -41,8 +46,16 @@ func (s *Sync) applyPut(ctx context.Context, group *errgroup.Group, localName st
}

group.Go(func() error {
localFile, err := os.Open(filepath.Join(s.LocalPath, localName))
if err != nil {
return err
}

defer localFile.Close()

s.notifyProgress(ctx, EventActionPut, localName, 0.0)
err := s.repoFiles.PutFile(ctx, localName)
opts := []filer.WriteMode{filer.CreateParentDirectories, filer.OverwriteIfExists}
err = s.filer.Write(ctx, localName, localFile, opts...)
if err != nil {
return err
}
Expand Down