mirror of https://github.com/databricks/cli.git
This commit is contained in:
parent
0382c749c5
commit
289dd0db32
|
@ -25,9 +25,11 @@ type SyncOptions struct {
|
||||||
|
|
||||||
Host string
|
Host string
|
||||||
|
|
||||||
// If set, sync will not be able to overwrite any existing paths on the
|
// Allow sync to overwrite existing files in the workspace
|
||||||
// workspace file system.
|
AllowOverwrites bool
|
||||||
DisallowOverwrites bool
|
|
||||||
|
// Persist the snapshot on the local file systems for future sync runs
|
||||||
|
PersistSnapshot bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Sync struct {
|
type Sync struct {
|
||||||
|
@ -80,9 +82,12 @@ func New(ctx context.Context, opts SyncOptions) (*Sync, error) {
|
||||||
return nil, fmt.Errorf("unable to load sync snapshot: %w", err)
|
return nil, fmt.Errorf("unable to load sync snapshot: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
repoFiles := repofiles.Create(opts.RemotePath, opts.LocalPath, opts.WorkspaceClient, &repofiles.RepoFileOptions{
|
repoFiles, err := repofiles.Create(opts.RemotePath, opts.LocalPath, opts.WorkspaceClient, &repofiles.RepoFileOptions{
|
||||||
OverwriteIfExists: !opts.DisallowOverwrites,
|
OverwriteIfExists: opts.AllowOverwrites,
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return &Sync{
|
return &Sync{
|
||||||
SyncOptions: &opts,
|
SyncOptions: &opts,
|
||||||
|
@ -163,10 +168,12 @@ func (s *Sync) RunOnce(ctx context.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = s.snapshot.Save(ctx)
|
if s.PersistSnapshot {
|
||||||
if err != nil {
|
err = s.snapshot.Save(ctx)
|
||||||
log.Errorf(ctx, "cannot store snapshot: %s", err)
|
if err != nil {
|
||||||
return err
|
log.Errorf(ctx, "cannot store snapshot: %s", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s.notifyComplete(ctx, change)
|
s.notifyComplete(ctx, change)
|
||||||
|
|
Loading…
Reference in New Issue