diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 957793f..5f7c6ec 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -20,14 +20,14 @@ jobs: - name: Bump version and push tag id: tag_version uses: mathieudutour/github-tag-action@v5.6 + env: + default_bump: minor with: github_token: ${{ secrets.GITHUB_TOKEN }} - name: Create Release id: create_release uses: softprops/action-gh-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: token: ${{ secrets.GITHUB_TOKEN }} body: ${{ steps.tag_version.outputs.changelog }} diff --git a/Compressor/Compression.go b/Compressor/Compression.go index 063276c..3a959a7 100644 --- a/Compressor/Compression.go +++ b/Compressor/Compression.go @@ -2,7 +2,6 @@ package Compressor import ( "archive/tar" - "bytes" "compress/flate" "compress/gzip" "fmt" @@ -18,9 +17,6 @@ import ( func CreateBakFile(fileName string, folderPath string, destinationPath string, backupName string) string { logger := Logging.DetailedLogger("Compression", "CreateBakFile") - var buf bytes.Buffer - compress(folderPath, &buf, backupName) - pathToFile := destinationPath + string(os.PathSeparator) + fileName + ".bak" @@ -28,10 +24,8 @@ func CreateBakFile(fileName string, folderPath string, destinationPath string, b if err != nil { logger.Fatal(err) } + compress(fileToWrite, folderPath, backupName) - if _, err := io.Copy(fileToWrite, &buf); err != nil { - logger.Fatal(err) - } SQL.NewLogEntry(SQL.GetSQLInstance(), uuid.New(), SQL.LogInfo, backupName, SQL.SQLStage_Compress, SQL.REMOTE_NONE, "File successfully written.", time.Now()) @@ -39,14 +33,13 @@ func CreateBakFile(fileName string, folderPath string, destinationPath string, b return fileName } - -func compress(folderPath string, buf io.Writer, backupName string){ +func compress(fileToWrite *os.File, folderPath string, backupName string){ logger := Logging.DetailedLogger("Gzip", "compress") - zr, _ := gzip.NewWriterLevel(buf, flate.BestCompression) + zr, _ := gzip.NewWriterLevel(fileToWrite, flate.BestCompression) tw := tar.NewWriter(zr) - fmt.Printf("[%s] Start compression...\n", filepath.Base(folderPath)) + go fmt.Printf("[%s] Start compression...\n", filepath.Base(folderPath)) SQL.NewLogEntry(SQL.GetSQLInstance(), uuid.New(), SQL.LogInfo, backupName, SQL.SQLStage_Compress, SQL.REMOTE_NONE, "Start compression", time.Now()) filepath.Walk(folderPath, func(file string, fi os.FileInfo, err error) error { header, err := tar.FileInfoHeader(fi, file) @@ -67,11 +60,12 @@ func compress(folderPath string, buf io.Writer, backupName string){ logger.Fatal(err) } - fmt.Printf("[%s] Compressing: %s (%d bytes)\n", filepath.Base(folderPath) ,relPath, fi.Size()) + go fmt.Printf("[%s] Compressing: %s (%d bytes)\n", filepath.Base(folderPath) ,relPath, fi.Size()) if _, err := io.Copy(tw, data); err != nil { logger.Fatal(err) } } + return nil }) @@ -84,6 +78,6 @@ func compress(folderPath string, buf io.Writer, backupName string){ } - fmt.Printf("[%s] Compression Done.\n", filepath.Base(folderPath)) + go fmt.Printf("[%s] Compression Done.\n", filepath.Base(folderPath)) SQL.NewLogEntry(SQL.GetSQLInstance(), uuid.New(), SQL.LogInfo, backupName, SQL.SQLStage_Compress, SQL.REMOTE_NONE, "Compression complete.", time.Now()) } \ No newline at end of file