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 6124dc0a
authored
Jan 07, 2022
by
shenyizhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* code review
1 parent
ae617de8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
18 deletions
src/httpcli/httpcli.go
src/main.go
src/travloc/travloc.go
src/httpcli/httpcli.go
View file @
6124dc0
package
httpcli
import
(
"bufio"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"minsync/auth"
...
...
@@ -192,10 +194,10 @@ func MkdirLoc(path string) {
}
}
func
Download
(
node
*
nodetree
.
NodeRemot
)
{
func
Download
(
node
*
nodetree
.
NodeRemot
)
error
{
tmpStrs
:=
strings
.
Split
(
node
.
Name
,
nodetree
.
StrSrc
)
if
len
(
tmpStrs
)
<
2
{
return
return
nil
}
// "/front/data/download?name=data/folder3/ddd.txt"
...
...
@@ -231,26 +233,26 @@ func Download(node *nodetree.NodeRemot) {
}
strDstFile
+=
tmpStrs
[
1
]
strCmd01
:=
strDstFile
strCmd02
:=
"
\"
"
+
jsonRes
.
Data
.
Url
+
"
\"
"
cmd
:=
exec
.
Command
(
"wget"
,
"-O"
,
strCmd01
,
strCmd02
)
log
.
Printf
(
"wget -O %v
\"
%v
\"
"
,
strDstFile
,
jsonRes
.
Data
.
Url
)
stdout
,
err
:=
cmd
.
StdoutPipe
(
)
res
,
err
:=
http
.
Get
(
jsonRes
.
Data
.
Url
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
fmt
.
Println
(
"error occurred!"
)
return
err
}
defer
stdout
.
Close
()
defer
res
.
Body
.
Close
()
// 获得get请求响应的reader对象
reader
:=
bufio
.
NewReaderSize
(
res
.
Body
,
32
*
1024
)
if
err
:=
cmd
.
Start
();
err
!=
nil
{
log
.
Fatal
(
err
)
file
,
err
:=
os
.
Create
(
strDstFile
)
if
err
!=
nil
{
panic
(
err
)
}
// 获得文件的writer对象
writer
:=
bufio
.
NewWriter
(
file
)
if
opBytes
,
err
:=
ioutil
.
ReadAll
(
stdout
);
err
!=
nil
{
log
.
Fatal
(
err
)
}
else
{
fmt
.
Printf
(
"File download successful : [%v] -> [%v]
\n
"
,
node
.
Name
,
strDstFile
)
log
.
Println
(
string
(
opBytes
))
}
written
,
_
:=
io
.
Copy
(
writer
,
reader
)
fmt
.
Printf
(
"File download successful : [%v] -> [%v], %v written
\n
"
,
nodetree
.
StrSrc
+
tmpStrs
[
1
],
strDstFile
,
written
)
return
nil
}
src/main.go
View file @
6124dc0
...
...
@@ -26,7 +26,7 @@ func printUsage() {
func
main
()
{
fmt
.
Println
(
"seetadm v0.0.
2
"
)
fmt
.
Println
(
"seetadm v0.0.
3
"
)
// seetadm --token ef0c26da821c upload /home/syz/tmp/abc /part1/box2
if
len
(
os
.
Args
)
<
6
{
...
...
src/travloc/travloc.go
View file @
6124dc0
...
...
@@ -66,6 +66,7 @@ func exploreRecursive(node *nodetree.NodeLoc, option *nodetree.OptionLoc, op str
// mkdir remot
httpcli
.
MkdirRemot
(
child
.
Path
)
log
.
Printf
(
"MkdirRemot(%v)"
,
child
.
Path
)
if
option
.
SubFlag
{
if
!
IsInSlice
(
option
.
IgnorePath
,
f
.
Name
())
{
...
...
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