mirror of
				https://github.com/kubenetworks/kubevpn.git
				synced 2025-10-31 18:52:50 +08:00 
			
		
		
		
	fix: download bug
This commit is contained in:
		| @@ -246,7 +246,7 @@ func (w *wsHandler) remoteInstallKubevpnIfCommandNotFound(ctx context.Context, s | |||||||
| 		w.Log("Get latest kubevpn version failed: %v", err) | 		w.Log("Get latest kubevpn version failed: %v", err) | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
| 	fmt.Printf("The latest version is: %s, commit: %s\n", latestVersion, latestCommit) | 	w.Log("The latest version is: %s, commit: %s", latestVersion, latestCommit) | ||||||
| 	var temp *os.File | 	var temp *os.File | ||||||
| 	temp, err = os.CreateTemp("", "") | 	temp, err = os.CreateTemp("", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| @@ -304,6 +304,7 @@ func (w *wsHandler) Log(format string, a ...any) { | |||||||
| 		str = fmt.Sprintf(format, a...) | 		str = fmt.Sprintf(format, a...) | ||||||
| 	} | 	} | ||||||
| 	w.conn.Write([]byte(str + "\r\n")) | 	w.conn.Write([]byte(str + "\r\n")) | ||||||
|  | 	log.Infof(format, a...) | ||||||
| } | } | ||||||
|  |  | ||||||
| func (w *wsHandler) PrintLine(msg string) { | func (w *wsHandler) PrintLine(msg string) { | ||||||
|   | |||||||
| @@ -72,7 +72,9 @@ func main(sess *ssh.Session, stdout, stderr io.Writer, filename string, to strin | |||||||
|  |  | ||||||
| func sCopy(dst io.Writer, src io.Reader, size int64, stdout, stderr io.Writer) error { | func sCopy(dst io.Writer, src io.Reader, size int64, stdout, stderr io.Writer) error { | ||||||
| 	total := float64(size) / 1024 / 1024 | 	total := float64(size) / 1024 / 1024 | ||||||
| 	log.Printf("Length: 68276642 (%0.2fM)\n", total) | 	s := fmt.Sprintf("Length: %d (%0.2fM)\n", size, total) | ||||||
|  | 	log.Info(s) | ||||||
|  | 	io.WriteString(stdout, s) | ||||||
|  |  | ||||||
| 	bar := progressbar.NewOptions(int(size), | 	bar := progressbar.NewOptions(int(size), | ||||||
| 		progressbar.OptionSetWriter(stdout), | 		progressbar.OptionSetWriter(stdout), | ||||||
|   | |||||||
| @@ -11,6 +11,7 @@ import ( | |||||||
| 	"strings" | 	"strings" | ||||||
|  |  | ||||||
| 	"github.com/schollz/progressbar/v3" | 	"github.com/schollz/progressbar/v3" | ||||||
|  | 	log "github.com/sirupsen/logrus" | ||||||
| 	utilerrors "k8s.io/apimachinery/pkg/util/errors" | 	utilerrors "k8s.io/apimachinery/pkg/util/errors" | ||||||
| 	"k8s.io/apimachinery/pkg/util/sets" | 	"k8s.io/apimachinery/pkg/util/sets" | ||||||
| ) | ) | ||||||
| @@ -88,7 +89,9 @@ func Download(client *http.Client, url string, filename string, stdout, stderr i | |||||||
| 	} | 	} | ||||||
| 	defer get.Body.Close() | 	defer get.Body.Close() | ||||||
| 	total := float64(get.ContentLength) / 1024 / 1024 | 	total := float64(get.ContentLength) / 1024 / 1024 | ||||||
| 	fmt.Printf("Length: 68276642 (%0.2fM)\n", total) | 	s := fmt.Sprintf("Length: %d (%0.2fM)\n", get.ContentLength, total) | ||||||
|  | 	log.Info(s) | ||||||
|  | 	io.WriteString(stdout, s) | ||||||
|  |  | ||||||
| 	var f *os.File | 	var f *os.File | ||||||
| 	f, err = os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755) | 	f, err = os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 fengcaiwen
					fengcaiwen