Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
K
koko
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
koko
Commits
1d06070a
Unverified
Commit
1d06070a
authored
Jul 22, 2019
by
Eric_Lee
Committed by
GitHub
Jul 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix sftp bugs (#58)
parent
099a50d0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
21 deletions
+27
-21
sftpconn.go
pkg/srvconn/sftpconn.go
+27
-21
No files found.
pkg/srvconn/sftpconn.go
View file @
1d06070a
...
...
@@ -186,12 +186,12 @@ func (u *UserSftp) RemoveDirectory(path string) error {
}
err
:=
u
.
removeDirectoryAll
(
conn
.
client
,
realPath
)
filename
:=
realPath
isSucess
:=
false
isSuc
c
ess
:=
false
operate
:=
model
.
OperateRemoveDir
if
err
==
nil
{
isSucess
=
true
isSuc
c
ess
=
true
}
u
.
CreateFTPLog
(
host
.
asset
,
su
,
operate
,
filename
,
isSucess
)
u
.
CreateFTPLog
(
host
.
asset
,
su
,
operate
,
filename
,
isSuc
c
ess
)
return
err
}
...
...
@@ -247,12 +247,12 @@ func (u *UserSftp) Remove(path string) error {
}
err
:=
conn
.
client
.
Remove
(
realPath
)
filename
:=
realPath
isSucess
:=
false
isSuc
c
ess
:=
false
operate
:=
model
.
OperateDelete
if
err
==
nil
{
isSucess
=
true
isSuc
c
ess
=
true
}
u
.
CreateFTPLog
(
host
.
asset
,
su
,
operate
,
filename
,
isSucess
)
u
.
CreateFTPLog
(
host
.
asset
,
su
,
operate
,
filename
,
isSuc
c
ess
)
return
err
}
...
...
@@ -283,12 +283,12 @@ func (u *UserSftp) MkdirAll(path string) error {
err
:=
conn
.
client
.
MkdirAll
(
realPath
)
filename
:=
realPath
isSucess
:=
false
isSuc
c
ess
:=
false
operate
:=
model
.
OperateMkdir
if
err
==
nil
{
isSucess
=
true
isSuc
c
ess
=
true
}
u
.
CreateFTPLog
(
host
.
asset
,
su
,
operate
,
filename
,
isSucess
)
u
.
CreateFTPLog
(
host
.
asset
,
su
,
operate
,
filename
,
isSuc
c
ess
)
return
err
}
...
...
@@ -320,12 +320,12 @@ func (u *UserSftp) Rename(oldNamePath, newNamePath string) error {
err
:=
conn1
.
client
.
Rename
(
oldRealPath
,
newRealPath
)
filename
:=
fmt
.
Sprintf
(
"%s=>%s"
,
oldRealPath
,
newRealPath
)
isSucess
:=
false
isSuc
c
ess
:=
false
operate
:=
model
.
OperateRename
if
err
==
nil
{
isSucess
=
true
isSuc
c
ess
=
true
}
u
.
CreateFTPLog
(
host
.
asset
,
su
,
operate
,
filename
,
isSucess
)
u
.
CreateFTPLog
(
host
.
asset
,
su
,
operate
,
filename
,
isSuc
c
ess
)
return
err
}
...
...
@@ -357,12 +357,12 @@ func (u *UserSftp) Symlink(oldNamePath, newNamePath string) error {
err
:=
conn1
.
client
.
Symlink
(
oldRealPath
,
newRealPath
)
filename
:=
fmt
.
Sprintf
(
"%s=>%s"
,
oldRealPath
,
newRealPath
)
isSucess
:=
false
isSuc
c
ess
:=
false
operate
:=
model
.
OperateSymlink
if
err
==
nil
{
isSucess
=
true
isSuc
c
ess
=
true
}
u
.
CreateFTPLog
(
host
.
asset
,
su
,
operate
,
filename
,
isSucess
)
u
.
CreateFTPLog
(
host
.
asset
,
su
,
operate
,
filename
,
isSuc
c
ess
)
return
err
}
...
...
@@ -393,12 +393,12 @@ func (u *UserSftp) Create(path string) (*sftp.File, error) {
}
sf
,
err
:=
conn
.
client
.
Create
(
realPath
)
filename
:=
realPath
isSucess
:=
false
isSuc
c
ess
:=
false
operate
:=
model
.
OperateUpload
if
err
==
nil
{
isSucess
=
true
isSuc
c
ess
=
true
}
u
.
CreateFTPLog
(
host
.
asset
,
su
,
operate
,
filename
,
isSucess
)
u
.
CreateFTPLog
(
host
.
asset
,
su
,
operate
,
filename
,
isSuc
c
ess
)
return
sf
,
err
}
...
...
@@ -427,12 +427,12 @@ func (u *UserSftp) Open(path string) (*sftp.File, error) {
}
sf
,
err
:=
conn
.
client
.
Open
(
realPath
)
filename
:=
realPath
isSucess
:=
false
isSuc
c
ess
:=
false
operate
:=
model
.
OperateDownaload
if
err
==
nil
{
isSucess
=
true
isSuc
c
ess
=
true
}
u
.
CreateFTPLog
(
host
.
asset
,
su
,
operate
,
filename
,
isSucess
)
u
.
CreateFTPLog
(
host
.
asset
,
su
,
operate
,
filename
,
isSuc
c
ess
)
return
sf
,
err
}
...
...
@@ -593,6 +593,9 @@ func (u *UserSftp) GetSftpClient(asset *model.Asset, sysUser *model.SystemUser)
func
(
u
*
UserSftp
)
Close
()
{
for
_
,
client
:=
range
u
.
sftpClients
{
if
client
==
nil
{
continue
}
client
.
Close
()
}
close
(
u
.
LogChan
)
...
...
@@ -645,6 +648,9 @@ type SftpConn struct {
}
func
(
s
*
SftpConn
)
Close
()
{
if
s
.
client
==
nil
{
return
}
_
=
s
.
client
.
Close
()
RecycleClient
(
s
.
conn
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment