Skip to content
This repository has been archived by the owner on Mar 2, 2020. It is now read-only.

Commit

Permalink
Check if revision exists before downloading
Browse files Browse the repository at this point in the history
The `sync` command is fairly slow even if the cache contains every revision being
synced. This is because a download is attempted even if it is unneeded.

This change changes the flow of `context.Sync` to attempt to `RevisionSync` with
whatever is in the cache, if that fails then it calls `Download` followed by
another `RevisionSync`.
  • Loading branch information
adamryman committed Jan 15, 2017
1 parent 6be156c commit 15edb8d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions context/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,17 +356,22 @@ func (ctx *Context) Sync(dryrun bool) (err error) {
continue
}
} else {
// Use cache.
vcsCmd = updateVcsCmd(sysVcsCmd)
err = vcsCmd.Download(repoRootDir)
if err != nil {
rem = append(rem, remoteFailure{Msg: "failed to download repo", Path: vp.Path, Err: err})
continue
}

err = vcsCmd.RevisionSync(repoRootDir, vp.Revision)
// If revision was not found in the cache, download and try again.
if err != nil {
rem = append(rem, remoteFailure{Msg: "failed to sync repo to " + vp.Revision, Path: vp.Path, Err: err})
continue
err = vcsCmd.Download(repoRootDir)
if err != nil {
rem = append(rem, remoteFailure{Msg: "failed to download repo", Path: vp.Path, Err: err})
continue
}
err = vcsCmd.RevisionSync(repoRootDir, vp.Revision)
if err != nil {
rem = append(rem, remoteFailure{Msg: "failed to sync repo to " + vp.Revision, Path: vp.Path, Err: err})
continue
}
}
}
dest := filepath.Join(ctx.RootDir, ctx.VendorFolder, pathos.SlashToFilepath(vp.Path))
Expand Down

0 comments on commit 15edb8d

Please sign in to comment.