Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
shenyizhong
/
minsync
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f351eb69
authored
Jan 09, 2022
by
Sayes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* code review
1 parent
6124dc0a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
src/httpcli/httpcli.go
src/main.go
src/httpcli/httpcli.go
View file @
f351eb6
...
...
@@ -155,7 +155,7 @@ func Upload(node *nodetree.NodeLoc) {
if
opBytes
,
err
:=
ioutil
.
ReadAll
(
stdout
);
err
!=
nil
{
log
.
Fatal
(
err
)
}
else
{
fmt
.
Printf
(
"
File uploaded successful : [%v] -> [%v]
\n
"
,
node
.
Path
,
nodetree
.
StrDst
+
tmpStrs
[
1
]
)
fmt
.
Printf
(
"
[%v]
\n
"
,
node
.
Path
)
log
.
Println
(
string
(
opBytes
))
}
}
...
...
@@ -235,6 +235,8 @@ func Download(node *nodetree.NodeRemot) error {
log
.
Printf
(
"wget -O %v
\"
%v
\"
"
,
strDstFile
,
jsonRes
.
Data
.
Url
)
fmt
.
Printf
(
"[%v] "
,
strDstFile
)
res
,
err
:=
http
.
Get
(
jsonRes
.
Data
.
Url
)
if
err
!=
nil
{
fmt
.
Println
(
"error occurred!"
)
...
...
@@ -252,7 +254,7 @@ func Download(node *nodetree.NodeRemot) error {
writer
:=
bufio
.
NewWriter
(
file
)
written
,
_
:=
io
.
Copy
(
writer
,
reader
)
fmt
.
Printf
(
"
File download successful : [%v] -> [%v], %v written
\n
"
,
nodetree
.
StrSrc
+
tmpStrs
[
1
],
strDstFile
,
written
)
fmt
.
Printf
(
"
%v bytes
\n
"
,
written
)
return
nil
}
src/main.go
View file @
f351eb6
...
...
@@ -71,6 +71,22 @@ func main() {
return
}
if
nodetree
.
StrOp
==
"download"
{
_
,
err
:=
os
.
Lstat
(
nodetree
.
StrDst
)
if
os
.
IsNotExist
(
err
)
{
fmt
.
Printf
(
"target path [%v] not exist
\n
"
,
nodetree
.
StrDst
)
return
}
}
if
nodetree
.
StrOp
==
"upload"
{
_
,
err
:=
os
.
Lstat
(
nodetree
.
StrSrc
)
if
os
.
IsNotExist
(
err
)
{
fmt
.
Printf
(
"source path [%v] not exist
\n
"
,
nodetree
.
StrSrc
)
return
}
}
_
,
err
:=
os
.
Lstat
(
nodetree
.
StrToken
)
if
!
os
.
IsNotExist
(
err
)
{
data
,
err
:=
ioutil
.
ReadFile
(
nodetree
.
StrToken
)
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment