Skip to content

Commit 02a75dc

Browse files
committed
update command
1 parent bf498b2 commit 02a75dc

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/ftpSync/syncFtp.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func (obj *SyncFtp) Sync(localFile, remoteFile string, numberTimes int) bool {
200200
return false
201201
}
202202

203-
func (obj *SyncFtp) ListFiles(remoteFolder string) ([]string, error) {
203+
func (obj *SyncFtp) ListFiles(remoteFolder string, recursion int) ([]string, error) {
204204
obj.Lock()
205205
defer obj.Unlock()
206206

@@ -212,10 +212,10 @@ func (obj *SyncFtp) ListFiles(remoteFolder string) ([]string, error) {
212212
remoteFolder = remoteFolder[:len(remoteFolder)-1]
213213
}
214214

215-
return obj.listFtpServerFolder(remoteFolder), nil
215+
return obj.listFtpServerFolder(remoteFolder, recursion), nil
216216
}
217217

218-
func (obj *SyncFtp) listFtpServerFolder(p string) []string {
218+
func (obj *SyncFtp) listFtpServerFolder(p string, recursion int) []string {
219219
fileEntryList, err := obj.syncFtpServer.List(p)
220220
if err != nil {
221221
obj.syncFtpServer = nil
@@ -226,7 +226,7 @@ func (obj *SyncFtp) listFtpServerFolder(p string) []string {
226226
folderFiles := make([]string, 0)
227227

228228
for _, e := range fileEntryList {
229-
if e.Type == ftp.EntryTypeLink {
229+
if e.Type == ftp.EntryTypeLink || InStringArray(e.Name, []string{".", ".."}){
230230
continue
231231
}
232232

@@ -238,8 +238,8 @@ func (obj *SyncFtp) listFtpServerFolder(p string) []string {
238238

239239
folderFiles = append(folderFiles, tp)
240240

241-
if e.Type == ftp.EntryTypeFolder {
242-
tf := obj.listFtpServerFolder(tp)
241+
if recursion == 1 && e.Type == ftp.EntryTypeFolder {
242+
tf := obj.listFtpServerFolder(tp, recursion)
243243
if tf != nil && len(tf) > 0 {
244244
folderFiles = append(folderFiles, tf...)
245245
}

src/ftpSync/syncServer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ func (obj *ftpSyncRedisHandler) FtpSync(localFile, remoteFile string) error {
4949
return errors.New("sync fail")
5050
}
5151

52-
func (obj *ftpSyncRedisHandler) Files(remoteFolder string) ([]string, error) {
52+
func (obj *ftpSyncRedisHandler) Files(remoteFolder string, recursionShow int) ([]string, error) {
5353
if len(remoteFolder) == 0 || strings.HasPrefix(remoteFolder, "/") == false {
5454
return nil, errors.New("error params")
5555
}
5656

57-
return GSyncFtp.ListFiles(remoteFolder)
57+
return GSyncFtp.ListFiles(remoteFolder, recursionShow)
5858
}
5959

6060
func (obj *ftpSyncRedisHandler) Delete(remoteFile string) error {

0 commit comments

Comments
 (0)