From 0561555da601a330bdc2db464c8dd5423d520306 Mon Sep 17 00:00:00 2001 From: Hitenjain14 Date: Mon, 24 Jul 2023 04:15:32 +0530 Subject: [PATCH 1/9] fix multi upload --- cmd/upload.go | 5 ++++- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/upload.go b/cmd/upload.go index f6fcb0f6..8edaf7ed 100644 --- a/cmd/upload.go +++ b/cmd/upload.go @@ -154,6 +154,7 @@ type MultiUploadOption struct { ThumbnailPath string `json:"thumbnailPath,omitempty"` Encrypt bool `json:"encrypt,omitempty"` ChunkNumber int `json:"chunkNumber,omitempty"` + IsUpdate bool `json:"isUpdate,omitempty"` } func multiUpload(allocationObj *sdk.Allocation, workdir, jsonMultiUploadOptions string, statusBar *StatusBar) error { @@ -179,6 +180,7 @@ func multiUpload(allocationObj *sdk.Allocation, workdir, jsonMultiUploadOptions thumbnailPaths := make([]string, totalUploads) chunkNumbers := make([]int, totalUploads) encrypts := make([]bool, totalUploads) + isUpdates := make([]bool, totalUploads) for idx, option := range options { statusBar.wg.Add(1) filePaths[idx] = option.FilePath @@ -187,9 +189,10 @@ func multiUpload(allocationObj *sdk.Allocation, workdir, jsonMultiUploadOptions remotePaths[idx] = option.RemotePath chunkNumbers[idx] = option.ChunkNumber encrypts[idx] = option.Encrypt + isUpdates[idx] = option.IsUpdate } - return allocationObj.StartMultiUpload(workdir, filePaths, fileNames, thumbnailPaths, encrypts, chunkNumbers, remotePaths, false, statusBar) + return allocationObj.StartMultiUpload(workdir, filePaths, fileNames, thumbnailPaths, encrypts, chunkNumbers, remotePaths, isUpdates, statusBar) } func init() { diff --git a/go.mod b/go.mod index e6db3187..f42a8e78 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/0chain/errors v1.0.3 - github.com/0chain/gosdk v1.8.17-0.20230722204836-1974594bc890 + github.com/0chain/gosdk v1.8.17-0.20230723190339-49fa44ee05a7 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 5bf33862..0ca77c82 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565 h1:z+DtCR8mBsjPnEs github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565/go.mod h1:UyDC8Qyl5z9lGkCnf9RHJPMektnFX8XtCJZHXCCVj8E= 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.8.17-0.20230722204836-1974594bc890 h1:T6aNrnqW2wXnIVWYJA6Lak9MwxVfERPbYemhThz8Iz4= -github.com/0chain/gosdk v1.8.17-0.20230722204836-1974594bc890/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4= +github.com/0chain/gosdk v1.8.17-0.20230723190339-49fa44ee05a7 h1:hRKry1noE3aT75SPj0OkG+25+s1dx3rWxIoxRVJYVxA= +github.com/0chain/gosdk v1.8.17-0.20230723190339-49fa44ee05a7/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4= 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/Luzifer/go-openssl/v3 v3.1.0 h1:QqKqo6kYXGGUsvtUoCpRZm8lHw+jDfhbzr36gVj+/gw= From 4b89e2df0f377c6f55ed3d54c039dc595abd44e6 Mon Sep 17 00:00:00 2001 From: Hitenjain14 Date: Mon, 24 Jul 2023 20:59:47 +0530 Subject: [PATCH 2/9] update gosdk --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f42a8e78..4b822925 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/0chain/errors v1.0.3 - github.com/0chain/gosdk v1.8.17-0.20230723190339-49fa44ee05a7 + github.com/0chain/gosdk v1.8.17-0.20230724152730-b890556cc3ab 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 0ca77c82..a38b1fbd 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565 h1:z+DtCR8mBsjPnEs github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565/go.mod h1:UyDC8Qyl5z9lGkCnf9RHJPMektnFX8XtCJZHXCCVj8E= 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.8.17-0.20230723190339-49fa44ee05a7 h1:hRKry1noE3aT75SPj0OkG+25+s1dx3rWxIoxRVJYVxA= -github.com/0chain/gosdk v1.8.17-0.20230723190339-49fa44ee05a7/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4= +github.com/0chain/gosdk v1.8.17-0.20230724152730-b890556cc3ab h1:7tW6nGz1hh2+teSPr191d0ctrDYIqJtAqxShNorFuqo= +github.com/0chain/gosdk v1.8.17-0.20230724152730-b890556cc3ab/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4= 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/Luzifer/go-openssl/v3 v3.1.0 h1:QqKqo6kYXGGUsvtUoCpRZm8lHw+jDfhbzr36gVj+/gw= From 0451e4b0b1843b0d9f071b28db52010d19d3224d Mon Sep 17 00:00:00 2001 From: Lz Date: Fri, 28 Jul 2023 16:53:27 +0800 Subject: [PATCH 3/9] chore(gomod): updated gosdk --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4b822925..0a5262c5 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/0chain/errors v1.0.3 - github.com/0chain/gosdk v1.8.17-0.20230724152730-b890556cc3ab + github.com/0chain/gosdk v1.8.17-0.20230728082943-21e088fcb73a 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 a38b1fbd..29dae4c2 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565 h1:z+DtCR8mBsjPnEs github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565/go.mod h1:UyDC8Qyl5z9lGkCnf9RHJPMektnFX8XtCJZHXCCVj8E= 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.8.17-0.20230724152730-b890556cc3ab h1:7tW6nGz1hh2+teSPr191d0ctrDYIqJtAqxShNorFuqo= -github.com/0chain/gosdk v1.8.17-0.20230724152730-b890556cc3ab/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4= +github.com/0chain/gosdk v1.8.17-0.20230728082943-21e088fcb73a h1:ISULA6e+UDy5+we1gZq9MQXzyZwfQQfcEXFiQzvuMLw= +github.com/0chain/gosdk v1.8.17-0.20230728082943-21e088fcb73a/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4= 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/Luzifer/go-openssl/v3 v3.1.0 h1:QqKqo6kYXGGUsvtUoCpRZm8lHw+jDfhbzr36gVj+/gw= From 69dd012e6da50d30d094f2b8549e101861ac0092 Mon Sep 17 00:00:00 2001 From: Lz Date: Fri, 4 Aug 2023 12:12:00 +0800 Subject: [PATCH 4/9] chore(git): merge latest sprint branch --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9f2b947d..f1f3b186 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/0chain/errors v1.0.3 - github.com/0chain/gosdk v1.8.17-0.20230803015000-36f9c3029847 + github.com/0chain/gosdk v1.8.17-0.20230803070325-6e55f87eb2ad 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 c9c8beff..53bd30f6 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565 h1:z+DtCR8mBsjPnEs github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565/go.mod h1:UyDC8Qyl5z9lGkCnf9RHJPMektnFX8XtCJZHXCCVj8E= 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.8.17-0.20230803015000-36f9c3029847 h1:rtug5RioIJTmhvlRjR6X0S/SU+BIS4AuoBBXw71lslE= -github.com/0chain/gosdk v1.8.17-0.20230803015000-36f9c3029847/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4= +github.com/0chain/gosdk v1.8.17-0.20230803070325-6e55f87eb2ad h1:xwTKBa/JXvKPV1T8G//ZuP6xbEbCU9EVYIAH0OBBMW0= +github.com/0chain/gosdk v1.8.17-0.20230803070325-6e55f87eb2ad/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4= 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/Luzifer/go-openssl/v3 v3.1.0 h1:QqKqo6kYXGGUsvtUoCpRZm8lHw+jDfhbzr36gVj+/gw= From e4639285a2fad6de845ce1bd5c88d05cff4dd515 Mon Sep 17 00:00:00 2001 From: Kishan-Dhakan Date: Wed, 23 Aug 2023 09:53:28 +0530 Subject: [PATCH 5/9] update gosdk --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6a0b87d0..e62607e8 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/0chain/errors v1.0.3 - github.com/0chain/gosdk v1.8.17-0.20230817042155-dfa775fd265d + github.com/0chain/gosdk v1.8.18-0.20230822202259-e9eac5bde02d 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 1dc5706d..4f834e49 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565 h1:z+DtCR8mBsjPnEs github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565/go.mod h1:UyDC8Qyl5z9lGkCnf9RHJPMektnFX8XtCJZHXCCVj8E= 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.8.17-0.20230817042155-dfa775fd265d h1:BlRkJoQGHJq7c+p/FGw6zxPXUoUhquxt9TL53+hXw2c= -github.com/0chain/gosdk v1.8.17-0.20230817042155-dfa775fd265d/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4= +github.com/0chain/gosdk v1.8.18-0.20230822202259-e9eac5bde02d h1:H54cunEyzQTcqICzX4mFxAv+ScDTOKb+6xR9kxybVmg= +github.com/0chain/gosdk v1.8.18-0.20230822202259-e9eac5bde02d/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4= 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/Luzifer/go-openssl/v3 v3.1.0 h1:QqKqo6kYXGGUsvtUoCpRZm8lHw+jDfhbzr36gVj+/gw= From 83eddc5be0279a59d57c2ee3783ebd86ceb622f1 Mon Sep 17 00:00:00 2001 From: Kishan Dhakan Date: Wed, 23 Aug 2023 19:43:35 +0530 Subject: [PATCH 6/9] update gosdk --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e62607e8..dc6fb68e 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/0chain/errors v1.0.3 - github.com/0chain/gosdk v1.8.18-0.20230822202259-e9eac5bde02d + github.com/0chain/gosdk v1.8.18-0.20230823135357-61db9486f4c0 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 4f834e49..b914f0e7 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565 h1:z+DtCR8mBsjPnEs github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565/go.mod h1:UyDC8Qyl5z9lGkCnf9RHJPMektnFX8XtCJZHXCCVj8E= 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.8.18-0.20230822202259-e9eac5bde02d h1:H54cunEyzQTcqICzX4mFxAv+ScDTOKb+6xR9kxybVmg= -github.com/0chain/gosdk v1.8.18-0.20230822202259-e9eac5bde02d/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4= +github.com/0chain/gosdk v1.8.18-0.20230823135357-61db9486f4c0 h1:XhLlPJKQxohZAS1+H2MHxy/e5I9Pw+Iyi+KaC5NHPl8= +github.com/0chain/gosdk v1.8.18-0.20230823135357-61db9486f4c0/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4= 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/Luzifer/go-openssl/v3 v3.1.0 h1:QqKqo6kYXGGUsvtUoCpRZm8lHw+jDfhbzr36gVj+/gw= From 4b89a5a301b377de4682957af35afbc5ecadc9e0 Mon Sep 17 00:00:00 2001 From: Hitenjain14 <57557631+Hitenjain14@users.noreply.github.com> Date: Thu, 24 Aug 2023 02:36:09 +0530 Subject: [PATCH 7/9] Update gosdk (#509) * update gosdk * update gosdk --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index dc6fb68e..c7ed8346 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/0chain/errors v1.0.3 - github.com/0chain/gosdk v1.8.18-0.20230823135357-61db9486f4c0 + github.com/0chain/gosdk v1.8.18-0.20230823172043-ea887d53014a 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 b914f0e7..033f8bd1 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565 h1:z+DtCR8mBsjPnEs github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565/go.mod h1:UyDC8Qyl5z9lGkCnf9RHJPMektnFX8XtCJZHXCCVj8E= 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.8.18-0.20230823135357-61db9486f4c0 h1:XhLlPJKQxohZAS1+H2MHxy/e5I9Pw+Iyi+KaC5NHPl8= -github.com/0chain/gosdk v1.8.18-0.20230823135357-61db9486f4c0/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4= +github.com/0chain/gosdk v1.8.18-0.20230823172043-ea887d53014a h1:SObqSMyLF+RAP+gLVN02DelKeAYDYAf3wa8f9RxuVIs= +github.com/0chain/gosdk v1.8.18-0.20230823172043-ea887d53014a/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4= 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/Luzifer/go-openssl/v3 v3.1.0 h1:QqKqo6kYXGGUsvtUoCpRZm8lHw+jDfhbzr36gVj+/gw= From 4e6b1dcd26fe49141a53518c53e6bea02e3e8552 Mon Sep 17 00:00:00 2001 From: Dinmukhammed Kambarov <52813950+din-mukhammed@users.noreply.github.com> Date: Mon, 28 Aug 2023 18:47:55 +0600 Subject: [PATCH 8/9] single fileops use DoMultiOperation (#506) * replace upload * change all ops to use multiop * fix upload paths * fix update * fix update * fix webstreaming * fixed update * point to specific gosdk * fix err messages * update gosdk * update gosdk * update gosdk * add webstreaming * uniform err messages * update gosdk --- cmd/copy.go | 11 +++++++-- cmd/createdir.go | 14 ++++++----- cmd/delete.go | 14 ++++++++--- cmd/download.go | 4 +-- cmd/move.go | 11 +++++++-- cmd/rename.go | 19 +++++++++----- cmd/update.go | 16 +++--------- cmd/upload.go | 64 +++++++++++++++++++++++++++++++----------------- go.mod | 2 +- go.sum | 4 +-- 10 files changed, 99 insertions(+), 60 deletions(-) diff --git a/cmd/copy.go b/cmd/copy.go index 5f2e5002..045d3098 100644 --- a/cmd/copy.go +++ b/cmd/copy.go @@ -4,6 +4,7 @@ import ( "fmt" "os" + "github.com/0chain/gosdk/constants" "github.com/0chain/gosdk/zboxcore/sdk" "github.com/spf13/cobra" ) @@ -40,9 +41,15 @@ var copyCmd = &cobra.Command{ remotePath := cmd.Flag("remotepath").Value.String() destPath := cmd.Flag("destpath").Value.String() - err = allocationObj.CopyObject(remotePath, destPath) + err = allocationObj.DoMultiOperation([]sdk.OperationRequest{ + { + OperationType: constants.FileOperationCopy, + RemotePath: remotePath, + DestPath: destPath, + }, + }) if err != nil { - PrintError("Error performing CopyObject", err) + PrintError("Copy failed.", err) os.Exit(1) } diff --git a/cmd/createdir.go b/cmd/createdir.go index 2decc0a9..12b0ec0d 100644 --- a/cmd/createdir.go +++ b/cmd/createdir.go @@ -4,6 +4,7 @@ import ( "fmt" "os" + "github.com/0chain/gosdk/constants" "github.com/0chain/gosdk/zboxcore/sdk" "github.com/spf13/cobra" ) @@ -32,14 +33,15 @@ var createDirCmd = &cobra.Command{ } dirname := cmd.Flag("dirname").Value.String() - if err != nil { - PrintError("CreateDir failed: ", err) - os.Exit(1) - } - err = allocationObj.CreateDir(dirname) + err = allocationObj.DoMultiOperation([]sdk.OperationRequest{ + { + OperationType: constants.FileOperationCreateDir, + RemotePath: dirname, + }, + }) if err != nil { - PrintError("CreateDir failed: ", err) + PrintError("Directory creation failed.", err) os.Exit(1) } diff --git a/cmd/delete.go b/cmd/delete.go index 2569ebeb..9259efcf 100644 --- a/cmd/delete.go +++ b/cmd/delete.go @@ -4,6 +4,7 @@ import ( "fmt" "os" + "github.com/0chain/gosdk/constants" "github.com/0chain/gosdk/zboxcore/sdk" "github.com/spf13/cobra" ) @@ -15,12 +16,12 @@ var deleteCmd = &cobra.Command{ Long: `delete file from blobbers`, Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { - fflags := cmd.Flags() // fflags is a *flag.FlagSet - if fflags.Changed("allocation") == false { // check if the flag "path" is set + fflags := cmd.Flags() // fflags is a *flag.FlagSet + if !fflags.Changed("allocation") { // check if the flag "path" is set PrintError("Error: allocation flag is missing") // If not, we'll let the user know os.Exit(1) // and return } - if fflags.Changed("remotepath") == false { + if !fflags.Changed("remotepath") { PrintError("Error: remotepath flag is missing") os.Exit(1) } @@ -33,7 +34,12 @@ var deleteCmd = &cobra.Command{ } remotePath := cmd.Flag("remotepath").Value.String() - err = allocationObj.DeleteFile(remotePath) + err = allocationObj.DoMultiOperation([]sdk.OperationRequest{ + { + OperationType: constants.FileOperationDelete, + RemotePath: remotePath, + }, + }) if err != nil { PrintError("Delete failed.", err.Error()) os.Exit(1) diff --git a/cmd/download.go b/cmd/download.go index eeff0bf0..35dfb9c5 100644 --- a/cmd/download.go +++ b/cmd/download.go @@ -139,7 +139,7 @@ var downloadCmd = &cobra.Command{ } } } else if len(remotePath) > 0 { - if fflags.Changed("allocation") == false { // check if the flag "path" is set + if !fflags.Changed("allocation") { // check if the flag "path" is set PrintError("Error: allocation flag is missing") // If not, we'll let the user know os.Exit(1) // and return } @@ -168,7 +168,7 @@ var downloadCmd = &cobra.Command{ } } } else if len(multidownloadJSON) > 0 { - if fflags.Changed("allocation") == false { // check if the flag "path" is set + if !fflags.Changed("allocation") { // check if the flag "path" is set PrintError("Error: allocation flag is missing") // If not, we'll let the user know os.Exit(1) // and return } diff --git a/cmd/move.go b/cmd/move.go index b1b47c59..d3909727 100644 --- a/cmd/move.go +++ b/cmd/move.go @@ -4,6 +4,7 @@ import ( "fmt" "os" + "github.com/0chain/gosdk/constants" "github.com/0chain/gosdk/zboxcore/sdk" "github.com/spf13/cobra" ) @@ -38,9 +39,15 @@ var moveCmd = &cobra.Command{ remotePath := cmd.Flag("remotepath").Value.String() destPath := cmd.Flag("destpath").Value.String() - err = allocationObj.MoveObject(remotePath, destPath) + err = allocationObj.DoMultiOperation([]sdk.OperationRequest{ + { + OperationType: constants.FileOperationMove, + RemotePath: remotePath, + DestPath: destPath, + }, + }) if err != nil { - PrintError("Error performing CopyObject", err) + PrintError("Move failed.", err) os.Exit(1) } diff --git a/cmd/rename.go b/cmd/rename.go index 59e8877e..3822a4af 100644 --- a/cmd/rename.go +++ b/cmd/rename.go @@ -4,6 +4,7 @@ import ( "fmt" "os" + "github.com/0chain/gosdk/constants" "github.com/0chain/gosdk/core/pathutil" "github.com/0chain/gosdk/zboxcore/sdk" "github.com/spf13/cobra" @@ -16,17 +17,17 @@ var renameCmd = &cobra.Command{ Long: `rename an object on blobbers`, Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { - fflags := cmd.Flags() // fflags is a *flag.FlagSet - if fflags.Changed("allocation") == false { // check if the flag "path" is set + fflags := cmd.Flags() // fflags is a *flag.FlagSet + if !fflags.Changed("allocation") { // check if the flag "path" is set PrintError("Error: allocation flag is missing") // If not, we'll let the user know os.Exit(1) // and os.Exit(1) } - if fflags.Changed("remotepath") == false { + if !fflags.Changed("remotepath") { PrintError("Error: remotepath flag is missing") os.Exit(1) } - if fflags.Changed("destname") == false { + if !fflags.Changed("destname") { PrintError("Error: destname flag is missing") os.Exit(1) } @@ -44,9 +45,15 @@ var renameCmd = &cobra.Command{ return } - err = allocationObj.RenameObject(remotePath, destName) + err = allocationObj.DoMultiOperation([]sdk.OperationRequest{ + { + OperationType: constants.FileOperationRename, + RemotePath: remotePath, + DestName: destName, + }, + }) if err != nil { - PrintError(err.Error()) + PrintError("Rename failed.", err) os.Exit(1) } fmt.Println(remotePath + " renamed") diff --git a/cmd/update.go b/cmd/update.go index eaf2f673..a6071799 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -16,11 +16,11 @@ var updateCmd = &cobra.Command{ Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { fflags := cmd.Flags() - if fflags.Changed("allocation") == false { + if !fflags.Changed("allocation") { PrintError("Error: allocation flag is missing") os.Exit(1) } - if fflags.Changed("remotepath") == false { + if !fflags.Changed("remotepath") { PrintError("Error: remotepath flag is missing") os.Exit(1) } @@ -47,17 +47,7 @@ var updateCmd = &cobra.Command{ wg := &sync.WaitGroup{} statusBar := &StatusBar{wg: wg} - wg.Add(1) - - err = startChunkedUpload(cmd, allocationObj, chunkedUploadArgs{ - localPath: localPath, - remotePath: remotePath, - thumbnailPath: thumbnailPath, - encrypt: encrypt, - chunkNumber: updateChunkNumber, - isUpdate: true, - // isRepair: false, - }, statusBar) + err = singleUpload(allocationObj, localPath, remotePath, thumbnailPath, encrypt, false, true, updateChunkNumber, statusBar) if err != nil { PrintError("Update failed.", err) diff --git a/cmd/upload.go b/cmd/upload.go index 8edaf7ed..420267e8 100644 --- a/cmd/upload.go +++ b/cmd/upload.go @@ -61,21 +61,10 @@ var uploadCmd = &cobra.Command{ if multiuploadJSON != "" { err = multiUpload(allocationObj, localPath, multiuploadJSON, statusBar) } else { - wg.Add(1) - err = startChunkedUpload(cmd, allocationObj, - chunkedUploadArgs{ - localPath: localPath, - thumbnailPath: thumbnailPath, - remotePath: remotePath, - encrypt: encrypt, - webStreaming: webStreaming, - chunkNumber: uploadChunkNumber, - // isUpdate: false, - // isRepair: false, - }, statusBar) + err = singleUpload(allocationObj, localPath, remotePath, thumbnailPath, encrypt, webStreaming, false, uploadChunkNumber, statusBar) } if err != nil { - PrintError("Upload failed.", err.Error()) + PrintError("Upload failed.", err) os.Exit(1) } wg.Wait() @@ -97,7 +86,7 @@ type chunkedUploadArgs struct { isRepair bool } -func startChunkedUpload(cmd *cobra.Command, allocationObj *sdk.Allocation, args chunkedUploadArgs, statusBar sdk.StatusCallback) error { +func startChunkedUpload(allocationObj *sdk.Allocation, args chunkedUploadArgs, statusBar sdk.StatusCallback) error { fileReader, err := os.Open(args.localPath) if err != nil { return err @@ -148,13 +137,14 @@ func startChunkedUpload(cmd *cobra.Command, allocationObj *sdk.Allocation, args } type MultiUploadOption struct { - FilePath string `json:"filePath,omitempty"` - FileName string `json:"fileName,omitempty"` - RemotePath string `json:"remotePath,omitempty"` - ThumbnailPath string `json:"thumbnailPath,omitempty"` - Encrypt bool `json:"encrypt,omitempty"` - ChunkNumber int `json:"chunkNumber,omitempty"` - IsUpdate bool `json:"isUpdate,omitempty"` + FilePath string `json:"filePath,omitempty"` + FileName string `json:"fileName,omitempty"` + RemotePath string `json:"remotePath,omitempty"` + ThumbnailPath string `json:"thumbnailPath,omitempty"` + Encrypt bool `json:"encrypt,omitempty"` + ChunkNumber int `json:"chunkNumber,omitempty"` + IsUpdate bool `json:"isUpdate,omitempty"` + IsWebstreaming bool `json:"isWebstreaming,omitempty"` } func multiUpload(allocationObj *sdk.Allocation, workdir, jsonMultiUploadOptions string, statusBar *StatusBar) error { @@ -173,6 +163,34 @@ func multiUpload(allocationObj *sdk.Allocation, workdir, jsonMultiUploadOptions return err } + return multiUploadWithOptions(allocationObj, workdir, options, statusBar) +} + +func singleUpload(allocationObj *sdk.Allocation, localPath, remotePath, thumbnailPath string, encrypt, isWebstreaming, isUpdate bool, chunkNumber int, statusBar *StatusBar) error { + fullRemotePath, fileName, err := fullPathAndFileNameForUpload(localPath, remotePath) + if err != nil { + return err + } + remotePath = pathutil.Dir(fullRemotePath) + "/" + options := []MultiUploadOption{ + { + FilePath: localPath, + FileName: fileName, + RemotePath: remotePath, + ThumbnailPath: thumbnailPath, + Encrypt: encrypt, + ChunkNumber: chunkNumber, + IsUpdate: isUpdate, + IsWebstreaming: isWebstreaming, + }, + } + + workdir := util.GetHomeDir() + + return multiUploadWithOptions(allocationObj, workdir, options, statusBar) +} + +func multiUploadWithOptions(allocationObj *sdk.Allocation, workdir string, options []MultiUploadOption, statusBar *StatusBar) error { totalUploads := len(options) filePaths := make([]string, totalUploads) fileNames := make([]string, totalUploads) @@ -181,6 +199,7 @@ func multiUpload(allocationObj *sdk.Allocation, workdir, jsonMultiUploadOptions chunkNumbers := make([]int, totalUploads) encrypts := make([]bool, totalUploads) isUpdates := make([]bool, totalUploads) + isWebstreaming := make([]bool, totalUploads) for idx, option := range options { statusBar.wg.Add(1) filePaths[idx] = option.FilePath @@ -190,9 +209,10 @@ func multiUpload(allocationObj *sdk.Allocation, workdir, jsonMultiUploadOptions chunkNumbers[idx] = option.ChunkNumber encrypts[idx] = option.Encrypt isUpdates[idx] = option.IsUpdate + isWebstreaming[idx] = option.IsWebstreaming } - return allocationObj.StartMultiUpload(workdir, filePaths, fileNames, thumbnailPaths, encrypts, chunkNumbers, remotePaths, isUpdates, statusBar) + return allocationObj.StartMultiUpload(workdir, filePaths, fileNames, thumbnailPaths, encrypts, chunkNumbers, remotePaths, isUpdates, isWebstreaming, statusBar) } func init() { diff --git a/go.mod b/go.mod index c7ed8346..1ea6c06f 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/0chain/errors v1.0.3 - github.com/0chain/gosdk v1.8.18-0.20230823172043-ea887d53014a + github.com/0chain/gosdk v1.8.18-0.20230827195410-39deea65eca2 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 033f8bd1..04ea921d 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565 h1:z+DtCR8mBsjPnEs github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565/go.mod h1:UyDC8Qyl5z9lGkCnf9RHJPMektnFX8XtCJZHXCCVj8E= 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.8.18-0.20230823172043-ea887d53014a h1:SObqSMyLF+RAP+gLVN02DelKeAYDYAf3wa8f9RxuVIs= -github.com/0chain/gosdk v1.8.18-0.20230823172043-ea887d53014a/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4= +github.com/0chain/gosdk v1.8.18-0.20230827195410-39deea65eca2 h1:zfDlOSfXsTBgCF4XC4x01Jo7brQRewppYkpAop+KM28= +github.com/0chain/gosdk v1.8.18-0.20230827195410-39deea65eca2/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4= 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/Luzifer/go-openssl/v3 v3.1.0 h1:QqKqo6kYXGGUsvtUoCpRZm8lHw+jDfhbzr36gVj+/gw= From 8f2b18e6ffe62e8ae4359d9ede357f0ff77c4b8f Mon Sep 17 00:00:00 2001 From: Kishan Dhakan Date: Fri, 1 Sep 2023 22:45:30 +0100 Subject: [PATCH 9/9] update gosdk to staging --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1ea6c06f..ad1747c5 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/0chain/errors v1.0.3 - github.com/0chain/gosdk v1.8.18-0.20230827195410-39deea65eca2 + github.com/0chain/gosdk v1.8.18-0.20230901213317-53d640a9b7f9 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 04ea921d..ea784d36 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565 h1:z+DtCR8mBsjPnEs github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565/go.mod h1:UyDC8Qyl5z9lGkCnf9RHJPMektnFX8XtCJZHXCCVj8E= 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.8.18-0.20230827195410-39deea65eca2 h1:zfDlOSfXsTBgCF4XC4x01Jo7brQRewppYkpAop+KM28= -github.com/0chain/gosdk v1.8.18-0.20230827195410-39deea65eca2/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4= +github.com/0chain/gosdk v1.8.18-0.20230901213317-53d640a9b7f9 h1:GHTdYTmhNY9genBkNWLXdn3Z1yCtcbSNkcIFaKrqBRU= +github.com/0chain/gosdk v1.8.18-0.20230901213317-53d640a9b7f9/go.mod h1:3NKNYzmnMIYqZwwwOgZwMmTW1DT1ZUAmKyVPmYQOiT4= 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/Luzifer/go-openssl/v3 v3.1.0 h1:QqKqo6kYXGGUsvtUoCpRZm8lHw+jDfhbzr36gVj+/gw=