Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
MKCLOS
Core Development Platform
coreospackage
Commits
296ed758
Commit
296ed758
authored
7 years ago
by
Ajit Jagtap
Browse files
Options
Downloads
Plain Diff
Merge branch 'DownloadHelper_SSS' into 'master'
Download Helper Changes See merge request
!27
parents
ed991d13
285e72c2
1 merge request
!27
Download Helper Changes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
downloadhelper/downloadHelper.go
+34
-25
downloadhelper/downloadHelper.go
with
34 additions
and
25 deletions
downloadhelper/downloadHelper.go
+
34
−
25
View file @
296ed758
...
...
@@ -2,7 +2,6 @@ package downloadhelper
import
(
"errors"
"os"
"strings"
"time"
...
...
@@ -34,27 +33,33 @@ func DownloadFile(sourcePath, destinationPath, jwtToken string, retryCnt int) (b
var
resp
*
grab
.
Response
for
index
:=
1
;
index
<=
retryCnt
;
index
++
{
resp
=
client
.
Do
(
req
)
t
:=
time
.
NewTicker
(
200
*
time
.
Millisecond
)
defer
t
.
Stop
()
Loop
:
for
{
select
{
// case <-t.C:
// logginghelper.LogInfo(" transferred %v / %v bytes (%.2f%%)\n",
// resp.BytesComplete(),
// resp.Size,
// 100*resp.Progress())
case
<-
resp
.
Done
:
// download is complete
break
Loop
}
if
resp
.
Size
<=
0
{
t
:=
time
.
NewTicker
(
200
*
time
.
Millisecond
)
defer
t
.
Stop
()
continue
}
// t := time.NewTicker(200 * time.Millisecond)
// defer t.Stop()
// Loop:
// for {
// select {
// // case <-t.C:
// // logginghelper.LogInfo(" transferred %v / %v bytes (%.2f%%)\n",
// // resp.BytesComplete(),
// // resp.Size,
// // 100*resp.Progress())
// case <-resp.Done:
// // download is complete
// break Loop
// }
// }
// check for errors
if
err
:=
resp
.
Err
();
err
!=
nil
{
logginghelper
.
LogError
(
os
.
Stderr
,
"Download failed: %v
\n
"
,
err
)
logginghelper
.
LogError
(
"Download failed: %v
\n
"
,
err
)
return
false
,
errors
.
New
(
"File not found on cloud"
)
}
...
...
@@ -62,16 +67,20 @@ func DownloadFile(sourcePath, destinationPath, jwtToken string, retryCnt int) (b
//resp, err = grab.Get(destinationPath, sourcePath)
if
resp
.
HTTPResponse
!=
nil
&&
(
resp
.
HTTPResponse
.
StatusCode
==
200
||
resp
.
HTTPResponse
.
StatusCode
==
206
)
{
return
true
,
nil
}
else
{
err
:=
filehelper
.
DeleteFile
(
destinationPath
)
if
err
!=
nil
{
logginghelper
.
LogError
(
"Error in deleting file
\n
: "
,
destinationPath
,
err
)
return
false
,
err
}
return
false
,
nil
}
err
:=
filehelper
.
DeleteFile
(
destinationPath
)
if
err
!=
nil
{
logginghelper
.
LogError
(
"Error in deleting file
\n
: "
,
destinationPath
,
err
)
return
false
,
err
}
return
false
,
nil
}
err
:=
filehelper
.
DeleteFile
(
destinationPath
)
if
err
!=
nil
{
logginghelper
.
LogError
(
"Error in deleting file
\n
: "
,
destinationPath
,
err
)
return
false
,
err
}
return
false
,
errors
.
New
(
"File not found on cloud"
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets