@@ -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 }
0 commit comments