Skip to content

Commit

Permalink
propate no-match found nil file after find* channel based queries
Browse files Browse the repository at this point in the history
Fixes #536.
Updates #528.
  • Loading branch information
odeke-em committed Dec 28, 2015
1 parent 6992e27 commit a4c784b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 18 deletions.
11 changes: 6 additions & 5 deletions src/changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,18 @@ func (g *Commands) changeListResolve(relToRoot, fsPath string, push bool) (cl, c
noClashThreshold := uint64(1)

for rem := range remotesChan {
if rem != nil && anyMatch(g.opts.IgnoreRegexp, rem.Name) {
return
if rem != nil {
if anyMatch(g.opts.IgnoreRegexp, rem.Name) {
return
}
iterCount++
}

iterCount++

ccl, cclashes, cErr := g.byRemoteResolve(relToRoot, fsPath, rem, push)

cl = append(cl, ccl...)
clashes = append(clashes, cclashes...)
if false && cErr != nil {
if cErr != nil {
err = reComposeError(err, cErr.Error())
}
}
Expand Down
11 changes: 9 additions & 2 deletions src/clashes.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,16 @@ func findClashesForChildren(g *Commands, parentId, relToRootPath string, depth i
memoized[child.Name] = cluster
}

separatorPrefix := relToRootPath
if rootLike(separatorPrefix) {
// Avoid a situation where you have Join("/", "/", "a") -> "//a"
separatorPrefix = ""
}

// To preserve the discovery order
for _, commonKey := range discoveryOrder {
cluster, _ := memoized[commonKey]
fullRelToRootPath := sepJoin(RemoteSeparator, relToRootPath, commonKey)
fullRelToRootPath := sepJoin(RemoteSeparator, separatorPrefix, commonKey)
nameClashesPresent := len(cluster) > 1

for _, rem := range cluster {
Expand Down Expand Up @@ -226,8 +232,9 @@ func autoRenameClashes(g *Commands, clashes []*Change) error {

var composedError error

quot := customQuote
for _, r := range renames {
message := fmt.Sprintf("Renaming %s %v -> %s\n", r.originalPath, r.change.Src.Id, r.newName)
message := fmt.Sprintf("Renaming %s %s -> %s\n", quot(r.originalPath), quot(r.change.Src.Id), quot(r.newName))
_, err := g.rem.rename(r.change.Src.Id, r.newName)
if err == nil {
g.log.Log(message)
Expand Down
1 change: 1 addition & 0 deletions src/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func (g *Commands) Id() (err error) {
iterCount := uint64(0)
for rem := range remotes {
if rem == nil {
err = reComposeError(err, fmt.Sprintf("%s does not exist remotely", customQuote(relToRootPath)))
continue
}

Expand Down
10 changes: 6 additions & 4 deletions src/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ func (g *Commands) PullPiped(byId bool) (err error) {
matches := resolver(relToRootPath)
for rem := range matches {
if rem == nil {
err = reComposeError(err, fmt.Sprintf("%s doesnot exist", customQuote(relToRootPath)))
continue
}

Expand Down Expand Up @@ -334,17 +335,18 @@ func (g *Commands) pullById() (cl, clashes []*Change, err error) {
}

func (g *Commands) pullByPath() (cl, clashes []*Change, err error) {
fmt.Println("pullByPath")
for _, relToRootPath := range g.opts.Sources {
fsPath := g.context.AbsPathOf(relToRootPath)
ccl, cclashes, cErr := g.changeListResolve(relToRootPath, fsPath, false)
clashes = append(clashes, cclashes...)
if cErr != nil && cErr != ErrClashesDetected {
return cl, clashes, cErr
if len(cclashes) > 0 {
clashes = append(clashes, cclashes...)
}
if len(ccl) > 0 {
cl = append(cl, ccl...)
}
if cErr != nil && cErr != ErrClashesDetected {
err = reComposeError(err, cErr.Error())
}
}

if len(clashes) >= 1 {
Expand Down
11 changes: 5 additions & 6 deletions src/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,21 +328,20 @@ func (g *Commands) playPushChanges(cl []*Change, opMap *map[Operation]sizeCounte
func lonePush(g *Commands, parent, absPath, path string) (cl, clashes []*Change, err error) {
remotesChan := g.rem.FindByPathM(absPath)

iterCount := uint64(0)
noClashThreshold := uint64(1)
var l *File
localinfo, _ := os.Stat(path)
if localinfo != nil {
l = NewLocalFile(path, localinfo)
}

iterCount := uint64(0)
noClashThreshold := uint64(1)

for r := range remotesChan {
if r == nil {
continue
if r != nil {
iterCount++
}

iterCount++

clr := &changeListResolve{
push: true,
dir: parent,
Expand Down
6 changes: 5 additions & 1 deletion src/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func reqDoPage(req *drive.FilesListCall, hidden bool, promptOnPagination bool) c
defer close(fileChan)

pageToken := ""
for {
for pageIterCount := uint64(0); ; pageIterCount++ {
if pageToken != "" {
req = req.PageToken(pageToken)
}
Expand All @@ -319,6 +319,10 @@ func reqDoPage(req *drive.FilesListCall, hidden bool, promptOnPagination bool) c
}
pageToken = results.NextPageToken
if pageToken == "" {
if len(results.Items) < 1 && pageIterCount < 1 {
// Item absolutely doesn't exist
fileChan <- nil
}
break
}

Expand Down

0 comments on commit a4c784b

Please sign in to comment.