From 606d0cba64f32de9d4d69470a3f7de29de4e0e2d Mon Sep 17 00:00:00 2001 From: qinguoyi <1532979219@qq.com> Date: Sat, 3 Aug 2024 00:46:37 +0800 Subject: [PATCH] Fix extractToFile gz file nil bug (#5847) --- weed/command/update.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/weed/command/update.go b/weed/command/update.go index 4f2b66b2e..bf871d654 100644 --- a/weed/command/update.go +++ b/weed/command/update.go @@ -20,8 +20,8 @@ import ( "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/util" - "golang.org/x/net/context/ctxhttp" util_http "github.com/seaweedfs/seaweedfs/weed/util/http" + "golang.org/x/net/context/ctxhttp" ) //copied from https://github.com/restic/restic/tree/master/internal/selfupdate @@ -309,7 +309,12 @@ func extractToFile(buf []byte, filename, target string) error { trd := tar.NewReader(gr) hdr, terr := trd.Next() if terr != nil { - glog.Errorf("uncompress file(%s) failed:%s", hdr.Name, terr) + if hdr != nil { + glog.Errorf("uncompress file(%s) failed:%s", hdr.Name, terr) + } else { + glog.Errorf("uncompress file is nil, failed:%s", terr) + } + return terr } rd = trd