Skip to content

Commit 4e95b38

Browse files
author
JojiiOfficial
committed
fix upload
1 parent a7314d7 commit 4e95b38

File tree

4 files changed

+15
-21
lines changed

4 files changed

+15
-21
lines changed

commands/FileDownload.go

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,7 @@ func (cData *CommandData) DownloadFile(data *DownloadData) {
158158
// await shredder
159159
<-c
160160
}, func(s string) {
161-
text := sPrintSuccess("saved '%s'", outFile)
162-
163-
// If a progressbar was used, set its text
164-
// instead of printing a new line
165-
if data.bar != nil {
166-
data.bar.SetText(text)
167-
} else {
168-
fmt.Println(text + "\n")
169-
}
170-
161+
printBar(sPrintSuccess("saved '%s'", outFile), data.bar)
171162
})
172163
}
173164

@@ -184,13 +175,3 @@ func writeFile(cData *CommandData, resp *libdm.FileDownloadResponse, file string
184175

185176
return err
186177
}
187-
188-
// If bar is set, use it to print text
189-
// Otherwise print a new line
190-
func printBar(text string, bar *uiprogress.Bar) {
191-
if bar == nil {
192-
fmt.Println(text)
193-
} else {
194-
bar.SetText(text)
195-
}
196-
}

commands/FileUtils.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
libdm "github.com/DataManager-Go/libdatamanager"
1515
"github.com/JojiiOfficial/gaw"
1616
"github.com/fatih/color"
17+
"github.com/gosuri/uiprogress"
1718
)
1819

1920
// determineDecryptionKey gets the correct decryption key from either the arguments of
@@ -156,3 +157,13 @@ func parseURIArgUploadCommand(uris []string) []string {
156157

157158
return newURIList
158159
}
160+
161+
// If bar is set, use it to print text
162+
// Otherwise print a new line
163+
func printBar(text string, bar *uiprogress.Bar) {
164+
if bar.IsValid() {
165+
bar.SetText(text)
166+
} else {
167+
fmt.Println(text)
168+
}
169+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/DataManager-Go/DataManagerCLI
22

33
go 1.14
44

5-
replace github.com/gosuri/uiprogress v0.0.1 => github.com/JojiiOfficial/uiprogress v1.0.4
5+
replace github.com/gosuri/uiprogress v0.0.1 => github.com/JojiiOfficial/uiprogress v1.0.5
66

77
require (
88
github.com/CovenantSQL/go-sqlite3-encrypt v1.9.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ github.com/JojiiOfficial/uiprogress v1.0.3 h1:FeSJKEPlfyUokrA4zi/hl6s3m2DAHdo8TX
2121
github.com/JojiiOfficial/uiprogress v1.0.3/go.mod h1:MsdctZCVERbGDu5lcgHZY12ANTIWkUjk7JyqGSTmQYg=
2222
github.com/JojiiOfficial/uiprogress v1.0.4 h1:2YL/YX6QoB5twDt2sK9cry5V277S5e9dEGzKelgOnGc=
2323
github.com/JojiiOfficial/uiprogress v1.0.4/go.mod h1:MsdctZCVERbGDu5lcgHZY12ANTIWkUjk7JyqGSTmQYg=
24+
github.com/JojiiOfficial/uiprogress v1.0.5 h1:aDvOcDRwXfDk6tsx6TmnjK3IAsbhzjJ3hZ4BpBZtotE=
25+
github.com/JojiiOfficial/uiprogress v1.0.5/go.mod h1:MsdctZCVERbGDu5lcgHZY12ANTIWkUjk7JyqGSTmQYg=
2426
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=
2527
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
2628
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=

0 commit comments

Comments
 (0)