From 2707d298ca67184d7dacc9bf10b1391cac3f0a17 Mon Sep 17 00:00:00 2001 From: Hitenjain14 Date: Tue, 24 Dec 2024 14:26:47 +0530 Subject: [PATCH 01/11] set verify to false --- cmd/sync.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/sync.go b/cmd/sync.go index e4de302f..39a3f67f 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -394,7 +394,7 @@ func init() { If file exists, this will be used for comparison with remote. After sync complete, remote snapshot will be updated to the same file for next use.`) syncCmd.PersistentFlags().StringArray("excludepath", []string{}, "Remote folder paths exclude to sync") - syncCmd.Flags().BoolP("verifydownload", "v", true, "pass this option to verify downloaded blocks") + syncCmd.Flags().BoolP("verifydownload", "v", false, "pass this option to verify downloaded blocks") syncCmd.MarkFlagRequired("allocation") syncCmd.MarkFlagRequired("localpath") From e23dbbaccc64b9ce4a03ede19e9d69fe8ca94379 Mon Sep 17 00:00:00 2001 From: Hitenjain14 Date: Thu, 2 Jan 2025 23:56:00 +0530 Subject: [PATCH 02/11] add filter for video files --- cmd/sync.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cmd/sync.go b/cmd/sync.go index 39a3f67f..9b92ec64 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -81,6 +81,30 @@ func filterEmptyFiles(localPath string, lDiff []sdk.FileDiff) (filterDiff []sdk. return } +func filterVideoFiles(localPath string, lDiff []sdk.FileDiff) (filterDiff []sdk.FileDiff) { + localPath = strings.TrimRight(localPath, "/") + for _, f := range lDiff { + path := localPath + f.Path + parentPath := filepath.Dir(path) + videoPath := filepath.Dir(parentPath) + //get extension of directory name + parentPathExt := filepath.Ext(parentPath) + if parentPathExt == "" && filepath.Base(parentPath) != "preview" { + filterDiff = append(filterDiff, f) + continue + } + if filepath.Base(path) == "thumbnail_generated.jpg" || filepath.Base(path) == "0kb" { + continue + } + + ext := filepath.Ext(videoPath) + if ext != ".mp4" && ext != ".mkv" && ext != ".avi" && ext != ".mov" && ext != ".flv" && ext != ".wmv" && ext != ".webm" { + filterDiff = append(filterDiff, f) + } + } + return +} + func startMultiUploadUpdate(allocationObj *sdk.Allocation, argsSlice []chunkedUploadArgs) error { totalOperations := len(argsSlice) if totalOperations == 0 { @@ -220,6 +244,7 @@ var syncCmd = &cobra.Command{ } lDiff = filterEmptyFiles(localpath, lDiff) + lDiff = filterVideoFiles(localpath, lDiff) if len(lDiff) > 0 { printTable(lDiff) From 4ddc61a8fdf929175ab1f76324decc6dba3d5156 Mon Sep 17 00:00:00 2001 From: shahnawaz-creator <117025384+shahnawaz-creator@users.noreply.github.com> Date: Sat, 4 Jan 2025 00:08:32 +0530 Subject: [PATCH 03/11] Update build-zbox.yaml --- .github/workflows/build-zbox.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-zbox.yaml b/.github/workflows/build-zbox.yaml index 3e0e792c..16fd72a0 100644 --- a/.github/workflows/build-zbox.yaml +++ b/.github/workflows/build-zbox.yaml @@ -106,7 +106,7 @@ jobs: build-macos: name: Build-macos - runs-on: macos-runner + runs-on: macos-latest steps: - name: Setup go 1.21 From 9aeb4cbb50274ebb6586876a08ec41db3d0ccdfc Mon Sep 17 00:00:00 2001 From: Hitenjain14 Date: Mon, 13 Jan 2025 21:03:46 +0530 Subject: [PATCH 04/11] add filter in diff --- cmd/sync.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/sync.go b/cmd/sync.go index 9b92ec64..d45ac51d 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -399,6 +399,7 @@ var getDiffCmd = &cobra.Command{ PrintError("Error getting diff.", err) os.Exit(1) } + lDiff = filterVideoFiles(localpath, lDiff) util.PrintJSON(lDiff) }, From b623297fe449877b6fdaa063ddafbc01702ce3ec Mon Sep 17 00:00:00 2001 From: Hitenjain14 Date: Mon, 13 Jan 2025 21:12:41 +0530 Subject: [PATCH 05/11] add filter for preview directory --- cmd/sync.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/sync.go b/cmd/sync.go index d45ac51d..bfc24d85 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -93,7 +93,7 @@ func filterVideoFiles(localPath string, lDiff []sdk.FileDiff) (filterDiff []sdk. filterDiff = append(filterDiff, f) continue } - if filepath.Base(path) == "thumbnail_generated.jpg" || filepath.Base(path) == "0kb" { + if filepath.Base(path) == "thumbnail_generated.jpg" || filepath.Base(path) == "0kb" || (f.Type == "d" && filepath.Base(path) == "preview") { continue } From 93a0d70a303d7b3dbf41207a7a521a939e461853 Mon Sep 17 00:00:00 2001 From: Hitenjain14 Date: Wed, 15 Jan 2025 15:03:00 +0530 Subject: [PATCH 06/11] use multi operation for delete --- cmd/sync.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/sync.go b/cmd/sync.go index bfc24d85..03f069e7 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -307,7 +307,11 @@ var syncCmd = &cobra.Command{ fileMetas[f.Path] = fileMeta // TODO: User confirm?? fmt.Printf("Deleting remote %s...\n", f.Path) - err = allocationObj.DeleteFile(f.Path) + opReq := sdk.OperationRequest{ + RemotePath: f.Path, + OperationType: constants.FileOperationDelete, + } + err = allocationObj.DoMultiOperation([]sdk.OperationRequest{opReq}) if err != nil { PrintError("Error deleting remote file,", err.Error()) } From 13b5fc22d8c379675b4f58f349ea71ce60ed763e Mon Sep 17 00:00:00 2001 From: Hitenjain14 Date: Thu, 30 Jan 2025 18:28:57 +0530 Subject: [PATCH 07/11] add option for log file path --- cmd/root.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 66b1abfd..c5b8e995 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -34,6 +34,7 @@ var bSilent bool var allocUnderRepair bool var walletJSON string +var logFilePath string var rootCmd = &cobra.Command{ Use: "zbox", @@ -58,6 +59,7 @@ func init() { rootCmd.PersistentFlags().StringVar(&cDir, "configDir", "", "configuration directory (default is $HOME/.zcn)") rootCmd.PersistentFlags().BoolVar(&bSilent, "silent", false, "(default false) Do not show interactive sdk logs (shown by default)") rootCmd.PersistentFlags().Float64Var(&txFee, "fee", 0, "transaction fee for the given transaction (if unset, it will be set to blockchain min fee)") + rootCmd.PersistentFlags().StringVar(&logFilePath, "log", "", "log file path (default is cmdlog.log)") } func Execute() { @@ -89,8 +91,12 @@ func initConfig() { logger.SyncLoggers([]*logger.Logger{zcncore.GetLogger(), sdk.GetLogger()}) // set the log file - zcncore.SetLogFile("cmdlog.log", !bSilent) - sdk.SetLogFile("cmdlog.log", !bSilent) + logPath := "cmdlog.log" + if logFilePath != "" { + logPath = logFilePath + } + zcncore.SetLogFile(logPath, !bSilent) + sdk.SetLogFile(logPath, !bSilent) err = client.Init(context.Background(), cfg) if err != nil { From 3a67ba845316b58321ac099c43d913381cdf0f51 Mon Sep 17 00:00:00 2001 From: Hitenjain14 Date: Thu, 30 Jan 2025 18:29:39 +0530 Subject: [PATCH 08/11] add option for log path --- cmd/root.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/root.go b/cmd/root.go index c5b8e995..3a62c082 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -59,7 +59,7 @@ func init() { rootCmd.PersistentFlags().StringVar(&cDir, "configDir", "", "configuration directory (default is $HOME/.zcn)") rootCmd.PersistentFlags().BoolVar(&bSilent, "silent", false, "(default false) Do not show interactive sdk logs (shown by default)") rootCmd.PersistentFlags().Float64Var(&txFee, "fee", 0, "transaction fee for the given transaction (if unset, it will be set to blockchain min fee)") - rootCmd.PersistentFlags().StringVar(&logFilePath, "log", "", "log file path (default is cmdlog.log)") + rootCmd.PersistentFlags().StringVar(&logFilePath, "log", "cmdlog.log", "log file path (default is cmdlog.log)") } func Execute() { From 86e0d0f50bd002f2aa74e568a6b3820278fb399b Mon Sep 17 00:00:00 2001 From: Hitenjain14 Date: Sun, 2 Feb 2025 17:12:12 +0530 Subject: [PATCH 09/11] set output in progress bar --- cmd/common.go | 6 ++++++ cmd/download.go | 9 +++++++++ cmd/root.go | 5 +---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/cmd/common.go b/cmd/common.go index 8b0f67f8..dec31352 100644 --- a/cmd/common.go +++ b/cmd/common.go @@ -2,6 +2,7 @@ package cmd import ( "fmt" + "io" "log" "os" "sync" @@ -16,6 +17,10 @@ const ( func (s *StatusBar) Started(allocationId, filePath string, op int, totalBytes int) { s.b = pb.StartNew(totalBytes) + if s.f != nil { + s.b.Output = s.f + s.b.NotPrint = true + } s.b.Set(0) } func (s *StatusBar) InProgress(allocationId, filePath string, op int, completedBytes int, data []byte) { @@ -60,6 +65,7 @@ func (s *StatusBar) RepairCompleted(filesRepaired int) { type StatusBar struct { b *pb.ProgressBar wg *sync.WaitGroup + f io.Writer success bool } diff --git a/cmd/download.go b/cmd/download.go index d404f2f8..29772825 100644 --- a/cmd/download.go +++ b/cmd/download.go @@ -81,6 +81,15 @@ var downloadCmd = &cobra.Command{ sdk.SetNumBlockDownloads(numBlocks) wg := &sync.WaitGroup{} statusBar := &StatusBar{wg: wg} + if logFilePath != "" { + f, err := os.Create(logFilePath) + if err != nil { + PrintError("Error creating log file", err) + os.Exit(1) + } + defer f.Close() + statusBar.f = f + } wg.Add(1) var errE error var allocationObj *sdk.Allocation diff --git a/cmd/root.go b/cmd/root.go index 3a62c082..07836d20 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -59,7 +59,7 @@ func init() { rootCmd.PersistentFlags().StringVar(&cDir, "configDir", "", "configuration directory (default is $HOME/.zcn)") rootCmd.PersistentFlags().BoolVar(&bSilent, "silent", false, "(default false) Do not show interactive sdk logs (shown by default)") rootCmd.PersistentFlags().Float64Var(&txFee, "fee", 0, "transaction fee for the given transaction (if unset, it will be set to blockchain min fee)") - rootCmd.PersistentFlags().StringVar(&logFilePath, "log", "cmdlog.log", "log file path (default is cmdlog.log)") + rootCmd.PersistentFlags().StringVar(&logFilePath, "log", "", "log file path where progress will be logged") } func Execute() { @@ -92,9 +92,6 @@ func initConfig() { // set the log file logPath := "cmdlog.log" - if logFilePath != "" { - logPath = logFilePath - } zcncore.SetLogFile(logPath, !bSilent) sdk.SetLogFile(logPath, !bSilent) From d95f26130202c607eb3d6d12785f1d1a6f2a3da6 Mon Sep 17 00:00:00 2001 From: shahnawaz-creator <117025384+shahnawaz-creator@users.noreply.github.com> Date: Sun, 2 Feb 2025 22:17:00 +0530 Subject: [PATCH 10/11] updated upload version to 4 --- .github/workflows/build-zbox.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-zbox.yaml b/.github/workflows/build-zbox.yaml index 16fd72a0..f6f9959a 100644 --- a/.github/workflows/build-zbox.yaml +++ b/.github/workflows/build-zbox.yaml @@ -40,7 +40,7 @@ jobs: make install - name: 'Upload Artifact' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: zbox-linux path: zbox @@ -93,7 +93,7 @@ jobs: zip zbox-windows.zip zbox.exe libgcc_s_seh-1.dll libstdc++-6.dll libwinpthread-1.dll - name: 'Upload Artifact' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: zbox-windows.zip path: zbox-windows.zip @@ -121,7 +121,7 @@ jobs: run: make install - name: 'Upload Artifact' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: zbox-macos path: zbox From 4062a7b0ea930980f01d4111a5950fc3ca9453c2 Mon Sep 17 00:00:00 2001 From: Hitenjain14 Date: Tue, 11 Feb 2025 00:09:32 +0530 Subject: [PATCH 11/11] update gosdk --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a4c3ef78..64a7837d 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ toolchain go1.22.5 require ( github.com/0chain/errors v1.0.3 - github.com/0chain/gosdk v1.19.0-RC2.0.20250117164514-4933fa5602a5 + github.com/0chain/gosdk v1.19.2 github.com/icza/bitio v1.1.0 github.com/olekukonko/tablewriter v0.0.5 github.com/spf13/cobra v1.6.0 diff --git a/go.sum b/go.sum index 97fa82c3..27081bfc 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/0chain/common v1.18.3 h1:42dYOv2KyMTSanuS67iDtfv+ErbSRqR8NJ3MG72MwaI= github.com/0chain/common v1.18.3/go.mod h1:Lapu2Tj7z5Sm4r+X141e7vsz4NDODTEypeElYAP3iSw= github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM= github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc= -github.com/0chain/gosdk v1.19.0-RC2.0.20250117164514-4933fa5602a5 h1:A8Ig1uLfMIaGtP4/m2X7/KZC9+thbsOJNBaMY/ZsycY= -github.com/0chain/gosdk v1.19.0-RC2.0.20250117164514-4933fa5602a5/go.mod h1:8unFy9Dx2YyPKMYPDGR3MFhUEymbAfQcRDm9bobVLGw= +github.com/0chain/gosdk v1.19.2 h1:OpGwtUAObAqU4HatQ8VM/Z+m07LG65NhF1dO/1q9RTs= +github.com/0chain/gosdk v1.19.2/go.mod h1:8unFy9Dx2YyPKMYPDGR3MFhUEymbAfQcRDm9bobVLGw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=