mirror of https://github.com/databricks/cli.git
Add `persist-snapshot` to bricks sync (#66)
Tested manually We are adding this flag because the default bricks sync is not robust against changing the profile and other project config changes. This will be used in the initial version of the vscode extention
This commit is contained in:
parent
7cad8bda81
commit
731679cb4b
|
@ -59,8 +59,11 @@ var interval *time.Duration
|
|||
|
||||
var remotePath *string
|
||||
|
||||
var persistSnapshot *bool
|
||||
|
||||
func init() {
|
||||
root.RootCmd.AddCommand(syncCmd)
|
||||
interval = syncCmd.Flags().Duration("interval", 1*time.Second, "project files polling interval")
|
||||
remotePath = syncCmd.Flags().String("remote-path", "", "remote path to store repo in. eg: /Repos/me@example.com/test-repo")
|
||||
persistSnapshot = syncCmd.Flags().Bool("persist-snapshot", true, "whether to store local snapshots of sync state")
|
||||
}
|
||||
|
|
|
@ -94,13 +94,14 @@ func (w *watchdog) main(ctx context.Context, applyDiff func(diff) error) {
|
|||
// load from json or sync it every time there's an action
|
||||
state := snapshot{}
|
||||
root := w.files.Root()
|
||||
if *persistSnapshot {
|
||||
err := state.loadSnapshot(root)
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] cannot load snapshot: %s", err)
|
||||
w.failure = err
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
|
@ -122,6 +123,7 @@ func (w *watchdog) main(ctx context.Context, applyDiff func(diff) error) {
|
|||
w.failure = err
|
||||
return
|
||||
}
|
||||
if *persistSnapshot {
|
||||
err = state.storeSnapshot(root)
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] cannot store snapshot: %s", err)
|
||||
|
@ -130,4 +132,5 @@ func (w *watchdog) main(ctx context.Context, applyDiff func(diff) error) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue