diff --git a/README.md b/README.md index a1c3da3ce0..34e4aee4ae 100644 --- a/README.md +++ b/README.md @@ -1088,6 +1088,7 @@ $ scw inspect myserver | jq '.[0].public_ip.address' #### Features +* Syncing cache to disk after server creation when running `scw run` in a non-detached mode * Bump to Golang 1.5 * Support --tmp-ssh-key `scw {run,create}` option ([#99](https://github.com/scaleway/scaleway-cli/issues/99)) * Support -f `scw run --rm` option ([#117](https://github.com/scaleway/scaleway-cli/issues/117)) diff --git a/pkg/api/cache.go b/pkg/api/cache.go index 8d927eebe1..ac97d7289f 100644 --- a/pkg/api/cache.go +++ b/pkg/api/cache.go @@ -15,6 +15,7 @@ import ( "sync" "github.com/scaleway/scaleway-cli/vendor/code.google.com/p/go-uuid/uuid" + "github.com/scaleway/scaleway-cli/vendor/github.com/Sirupsen/logrus" "github.com/scaleway/scaleway-cli/vendor/github.com/renstrom/fuzzysearch/fuzzy" ) @@ -177,6 +178,8 @@ func (c *ScalewayCache) Save() error { c.Lock.Lock() defer c.Lock.Unlock() + logrus.Debugf("Writing cache file to disk") + if c.Modified { file, err := ioutil.TempFile("", "") if err != nil { diff --git a/pkg/commands/run.go b/pkg/commands/run.go index 06018b034d..0e3f583820 100644 --- a/pkg/commands/run.go +++ b/pkg/commands/run.go @@ -103,6 +103,9 @@ func Run(ctx CommandContext, args RunArgs) error { if args.Detach { fmt.Fprintln(ctx.Stdout, serverID) return nil + } else { + // Sync cache on disk + ctx.API.Sync() } if args.Attach {