From 9303b69ea569bcb5e581147543a3fd58e90d0d25 Mon Sep 17 00:00:00 2001
From: sunty <1172534965@qq.com>
Date: 星期四, 20 八月 2020 20:05:23 +0800
Subject: [PATCH] add get buckets contrl

---
 service/SysService.go |   34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/service/SysService.go b/service/SysService.go
index 6108ca1..62c1d04 100644
--- a/service/SysService.go
+++ b/service/SysService.go
@@ -77,7 +77,7 @@
 		dirFiles, _ := ioutil.ReadDir(fileTmpPath)
 		if dirFiles != nil && len(dirFiles) == arg.TotalChunks {
 			//琛ㄧず鎵�鏈夊垎鍧楅兘涓婁紶浜嗭紝闇�瑕乵erge
-			if !sv.MergeChunks(fileTmpPath, mergedFilePath) {
+			if !MergeChunks(fileTmpPath, mergedFilePath) {
 				return false
 			}
 		}
@@ -85,7 +85,7 @@
 	return true
 }
 
-func (sv SysService) PatchUpload(arg *FileUploadVo) bool {
+func (sv SysService) PatchUpload(arg *FileUploadVo) (bool,bool) {
 	configPatchPath := ""
 	if config.Server.PatchPath != "" {
 		configPatchPath = config.Server.PatchPath
@@ -94,7 +94,7 @@
 	}
 	defer (*arg.File).Close()
 	if !util.CreateDirectory(configPatchPath) {
-		return false
+		return false, false
 	}
 
 	filenameWithSuffix := path.Base(arg.Header.Filename)
@@ -104,7 +104,7 @@
 	fileTmpPath := configPatchPath + "/"+MD5Str
 	if !util.Exists(fileTmpPath) {
 		if !util.CreateDirectory(fileTmpPath) {
-			return false
+			return false, false
 		}
 	}
 	chunkAlignNum := util.FormatNum(arg.TotalChunks, arg.ChunkNumber)
@@ -113,13 +113,13 @@
 		rmErr := os.Remove(fileSavePath)
 		if rmErr != nil {
 			logger.Debug("rmErr:",rmErr)
-			return false
+			return false, false
 		}
 	}
 	file, e := os.Create(fileSavePath)
 	if e !=nil {
 		logger.Debug("os.Create err:",e,"fileSavePath:",fileSavePath)
-		return false
+		return false, false
 	}
 	defer file.Close()
 	writer := bufio.NewWriter(file)
@@ -127,12 +127,12 @@
 	n, err := (*arg.File).ReadAt(chunkData, 0)
 	if n ==0 || err !=nil {
 		logger.Debug("read chunkData err:",err,"n:",n)
-		return false
+		return false, false
 	}
 	nn, err2 := writer.Write(chunkData)
 	if nn ==0 || err2 !=nil {
 		logger.Debug("write chunkData err:",err2,"nn:",nn)
-		return false
+		return false, false
 	}
 	if err = writer.Flush(); err != nil {
 		logger.Debug("write flush err:",err)
@@ -143,13 +143,13 @@
 		isComplete = true
 	}
 	if isComplete {
-		if sv.MergeChunks(fileTmpPath,fileTmpPath + subfix) {
+		if MergeChunks(fileTmpPath,fileTmpPath + subfix) {
 			logger.Debug("merge all chunks success,identifier:",MD5Str,"fileName:",arg.FileName)
 		} else {
-			return false
+			return false, isComplete
 		}
 	}
-	return true
+	return true, isComplete
 }
 
 //upgrade
@@ -234,10 +234,10 @@
 		return false
 	}
 
-	zipFilePath := configPatchPath+"/"+identifier+ext
-	err := util.DeCompress(zipFilePath, unPackPath)
+	unPackFilePath := configPatchPath+"/"+identifier+ext
+	err := util.UnTarGz(unPackFilePath, unPackPath)
 	if err !=nil {
-		logger.Debug("UnZip err:",err,"zipFile:",zipFilePath)
+		logger.Debug("UnPack err:",err,"unPackFile:",unPackFilePath)
 		return false
 	}
 
@@ -252,9 +252,9 @@
 	}
 
 	//鍒ゆ柇鏇存柊鍖呴噷鏄惁鏈夎ˉ涓佽剼鏈紝濡傛灉鏈夊垯鎵ц锛屽惁鍒欐墽琛寀pdatePatch.sh
-	updateCmd := fmt.Sprintf("./updatePatch.sh %s %s %s &",unPackPath,zipFilePath,configPatchPath+"/"+identifier)
+	updateCmd := fmt.Sprintf("./updatePatch.sh %s %s %s &",unPackPath,unPackFilePath,configPatchPath+"/"+identifier)
 	if util.Exists(unPackPath+"upgrade.sh") {
-		updateCmd = fmt.Sprintf("%supgrade.sh %s %s %s &",unPackPath,unPackPath,zipFilePath,configPatchPath+"/"+identifier)
+		updateCmd = fmt.Sprintf("%supgrade.sh %s %s %s &",unPackPath,unPackPath,unPackFilePath,configPatchPath+"/"+identifier)
 	}
 	//2.鏇存柊绯荤粺
 	b,err := ExecCmd(updateCmd)
@@ -267,7 +267,7 @@
 	return true
 }
 
-func (sv SysService) MergeChunks(chunkPath string, storePath string) bool {
+func MergeChunks(chunkPath string, storePath string) bool {
 	var cmd *exec.Cmd
 	cmd = exec.Command("/bin/sh", "-c", fmt.Sprintf("./mergeAll.sh %s %s", chunkPath, storePath))
 	if b, err := cmd.Output(); err != nil {

--
Gitblit v1.8.0