use the channel scanner when pushing ALL objects

This commit is contained in:
Rick Olson 2015-09-09 16:16:26 -06:00
parent bff5aa7b7e
commit 75d754a561

@ -1,6 +1,7 @@
package commands
import (
"fmt"
"io/ioutil"
"os"
@ -43,10 +44,23 @@ func uploadsBetweenRefAndRemote(remote string, refs []string) *lfs.TransferQueue
if pushAll {
if len(refs) == 0 {
// no ref given as an arg, so scan all refs
pointers, err := lfs.ScanRefs("", "", scanOpt)
opts := &lfs.ScanRefsOptions{ScanMode: lfs.ScanAllMode, SkipDeletedBlobs: false}
// This could be a long process so use the chan version & report progress
Print("Scanning for all objects ever referenced...")
spinner := lfs.NewSpinner()
var numObjs int64
pointerchan, err := lfs.ScanRefsToChan("", "", opts)
if err != nil {
Panic(err, "Error scanning for all Git LFS files")
Panic(err, "Could not scan for Git LFS files")
}
pointers := make([]*lfs.WrappedPointer, 0)
for p := range pointerchan {
numObjs++
spinner.Print(OutputWriter, fmt.Sprintf("%d objects found", numObjs))
pointers = append(pointers, p)
}
spinner.Finish(OutputWriter, fmt.Sprintf("%d objects found", numObjs))
Print("Pushing objects...")
return uploadPointers(pointers)
} else {
scanOpt.ScanMode = lfs.ScanRefsMode