@@ -198,8 +198,7 @@ func setExcludePaths(syncClient *SyncConfig) {
198198func createTestFilesAndFolders (local string , remote string ) ([]checkedFileOrFolder , []checkedFileOrFolder ) {
199199
200200 //Write local files
201- ioutil .WriteFile (path .Join (local , "testFileLocal1" ), []byte (fileContents ), 0666 )
202- ioutil .WriteFile (path .Join (local , "testFileLocal2" ), []byte (fileContents ), 0666 )
201+ ioutil .WriteFile (path .Join (local , "testFileLocal" ), []byte (fileContents ), 0666 )
203202 ioutil .WriteFile (path .Join (local , "ignoreFileLocal" ), []byte (fileContents ), 0666 )
204203 ioutil .WriteFile (path .Join (local , "noDownloadFileLocal" ), []byte (fileContents ), 0666 )
205204 ioutil .WriteFile (path .Join (local , "noUploadFileLocal" ), []byte (fileContents ), 0666 )
@@ -210,15 +209,13 @@ func createTestFilesAndFolders(local string, remote string) ([]checkedFileOrFold
210209 os .Mkdir (path .Join (local , "noDownloadFolderLocal" ), 0755 )
211210 os .Mkdir (path .Join (local , "noUploadFolderLocal" ), 0755 )
212211
213- ioutil .WriteFile (path .Join (local , "testFolder" , "testFileLocal1" ), []byte (fileContents ), 0666 )
214- ioutil .WriteFile (path .Join (local , "testFolder" , "testFileLocal2" ), []byte (fileContents ), 0666 )
212+ ioutil .WriteFile (path .Join (local , "testFolder" , "testFileLocal" ), []byte (fileContents ), 0666 )
215213 ioutil .WriteFile (path .Join (local , "testFolder" , "ignoreFileLocal" ), []byte (fileContents ), 0666 )
216214 ioutil .WriteFile (path .Join (local , "testFolder" , "noDownloadFileLocal" ), []byte (fileContents ), 0666 )
217215 ioutil .WriteFile (path .Join (local , "testFolder" , "noUploadFileLocal" ), []byte (fileContents ), 0666 )
218216
219217 // Write remote files
220- ioutil .WriteFile (path .Join (remote , "testFileRemote1" ), []byte (fileContents ), 0666 )
221- ioutil .WriteFile (path .Join (remote , "testFileRemote2" ), []byte (fileContents ), 0666 )
218+ ioutil .WriteFile (path .Join (remote , "testFileRemote" ), []byte (fileContents ), 0666 )
222219 ioutil .WriteFile (path .Join (remote , "ignoreFileRemote" ), []byte (fileContents ), 0666 )
223220 ioutil .WriteFile (path .Join (remote , "noDownloadFileRemote" ), []byte (fileContents ), 0666 )
224221 ioutil .WriteFile (path .Join (remote , "noUploadFileRemote" ), []byte (fileContents ), 0666 )
@@ -229,16 +226,14 @@ func createTestFilesAndFolders(local string, remote string) ([]checkedFileOrFold
229226 os .Mkdir (path .Join (remote , "noDownloadFolderRemote" ), 0755 )
230227 os .Mkdir (path .Join (remote , "noUploadFolderRemote" ), 0755 )
231228
232- ioutil .WriteFile (path .Join (remote , "testFolder" , "testFileRemote1" ), []byte (fileContents ), 0666 )
233- ioutil .WriteFile (path .Join (remote , "testFolder" , "testFileRemote2" ), []byte (fileContents ), 0666 )
229+ ioutil .WriteFile (path .Join (remote , "testFolder" , "testFileRemote" ), []byte (fileContents ), 0666 )
234230 ioutil .WriteFile (path .Join (remote , "testFolder" , "ignoreFileRemote" ), []byte (fileContents ), 0666 )
235231 ioutil .WriteFile (path .Join (remote , "testFolder" , "noDownloadFileRemote" ), []byte (fileContents ), 0666 )
236232 ioutil .WriteFile (path .Join (remote , "testFolder" , "noUploadFileRemote" ), []byte (fileContents ), 0666 )
237233
238234 //-----------The following files will be removed later-------------------------------------
239235 //Write local files
240- ioutil .WriteFile (path .Join (local , "testFileLocal1_Remove" ), []byte (fileContents ), 0666 )
241- ioutil .WriteFile (path .Join (local , "testFileLocal2_Remove" ), []byte (fileContents ), 0666 )
236+ ioutil .WriteFile (path .Join (local , "testFileLocal_Remove" ), []byte (fileContents ), 0666 )
242237 ioutil .WriteFile (path .Join (local , "ignoreFileLocal_Remove" ), []byte (fileContents ), 0666 )
243238 ioutil .WriteFile (path .Join (local , "noDownloadFileLocal_Remove" ), []byte (fileContents ), 0666 )
244239 ioutil .WriteFile (path .Join (local , "noUploadFileLocal_Remove" ), []byte (fileContents ), 0666 )
@@ -249,39 +244,30 @@ func createTestFilesAndFolders(local string, remote string) ([]checkedFileOrFold
249244 os .Mkdir (path .Join (local , "noDownloadFolderLocal_Remove" ), 0755 )
250245 os .Mkdir (path .Join (local , "noUploadFolderLocal_Remove" ), 0755 )
251246
252- ioutil .WriteFile (path .Join (local , "testFolder" , "testFileLocal1_Remove" ), []byte (fileContents ), 0666 )
253- ioutil .WriteFile (path .Join (local , "testFolder" , "testFileLocal2_Remove" ), []byte (fileContents ), 0666 )
247+ ioutil .WriteFile (path .Join (local , "testFolder" , "testFileLocal_Remove" ), []byte (fileContents ), 0666 )
254248 ioutil .WriteFile (path .Join (local , "testFolder" , "ignoreFileLocal_Remove" ), []byte (fileContents ), 0666 )
255249 ioutil .WriteFile (path .Join (local , "testFolder" , "noDownloadFileLocal_Remove" ), []byte (fileContents ), 0666 )
256250 ioutil .WriteFile (path .Join (local , "testFolder" , "noUploadFileLocal_Remove" ), []byte (fileContents ), 0666 )
257251
258252 // Write remote files
259- ioutil .WriteFile (path .Join (remote , "testFileRemote1_Remove" ), []byte (fileContents ), 0666 )
260- ioutil .WriteFile (path .Join (remote , "testFileRemote2_Remove" ), []byte (fileContents ), 0666 )
253+ ioutil .WriteFile (path .Join (remote , "testFileRemote_Remove" ), []byte (fileContents ), 0666 )
261254 ioutil .WriteFile (path .Join (remote , "ignoreFileRemote_Remove" ), []byte (fileContents ), 0666 )
262255 ioutil .WriteFile (path .Join (remote , "noDownloadFileRemote_Remove" ), []byte (fileContents ), 0666 )
263256 ioutil .WriteFile (path .Join (remote , "noUploadFileRemote_Remove" ), []byte (fileContents ), 0666 )
264257
265- os .Mkdir (path .Join (remote , "testFolder_Remove" ), 0755 )
266258 os .Mkdir (path .Join (remote , "testFolderRemote_Remove" ), 0755 )
267259 os .Mkdir (path .Join (remote , "ignoreFolderRemote_Remove" ), 0755 )
268260 os .Mkdir (path .Join (remote , "noDownloadFolderRemote_Remove" ), 0755 )
269261 os .Mkdir (path .Join (remote , "noUploadFolderRemote_Remove" ), 0755 )
270262
271- ioutil .WriteFile (path .Join (remote , "testFolder" , "testFileRemote1_Remove" ), []byte (fileContents ), 0666 )
272- ioutil .WriteFile (path .Join (remote , "testFolder" , "testFileRemote2_Remove" ), []byte (fileContents ), 0666 )
263+ ioutil .WriteFile (path .Join (remote , "testFolder" , "testFileRemote_Remove" ), []byte (fileContents ), 0666 )
273264 ioutil .WriteFile (path .Join (remote , "testFolder" , "ignoreFileRemote_Remove" ), []byte (fileContents ), 0666 )
274265 ioutil .WriteFile (path .Join (remote , "testFolder" , "noDownloadFileRemote_Remove" ), []byte (fileContents ), 0666 )
275266 ioutil .WriteFile (path .Join (remote , "testFolder" , "noUploadFileRemote_Remove" ), []byte (fileContents ), 0666 )
276267
277268 filesToCheck := []checkedFileOrFolder {
278269 checkedFileOrFolder {
279- path : "testFileLocal1" ,
280- shouldExistInLocal : true ,
281- shouldExistInRemote : true ,
282- },
283- checkedFileOrFolder {
284- path : "testFileLocal2" ,
270+ path : "testFileLocal" ,
285271 shouldExistInLocal : true ,
286272 shouldExistInRemote : true ,
287273 },
@@ -301,12 +287,7 @@ func createTestFilesAndFolders(local string, remote string) ([]checkedFileOrFold
301287 shouldExistInRemote : false ,
302288 },
303289 checkedFileOrFolder {
304- path : "testFolder/testFileLocal1" ,
305- shouldExistInLocal : true ,
306- shouldExistInRemote : true ,
307- },
308- checkedFileOrFolder {
309- path : "testFolder/testFileLocal2" ,
290+ path : "testFolder/testFileLocal" ,
310291 shouldExistInLocal : true ,
311292 shouldExistInRemote : true ,
312293 },
@@ -327,12 +308,7 @@ func createTestFilesAndFolders(local string, remote string) ([]checkedFileOrFold
327308 },
328309
329310 checkedFileOrFolder {
330- path : "testFileRemote1" ,
331- shouldExistInLocal : true ,
332- shouldExistInRemote : true ,
333- },
334- checkedFileOrFolder {
335- path : "testFileRemote2" ,
311+ path : "testFileRemote" ,
336312 shouldExistInLocal : true ,
337313 shouldExistInRemote : true ,
338314 },
@@ -352,12 +328,7 @@ func createTestFilesAndFolders(local string, remote string) ([]checkedFileOrFold
352328 shouldExistInRemote : true ,
353329 },
354330 checkedFileOrFolder {
355- path : "testFolder/testFileRemote1" ,
356- shouldExistInLocal : true ,
357- shouldExistInRemote : true ,
358- },
359- checkedFileOrFolder {
360- path : "testFolder/testFileRemote2" ,
331+ path : "testFolder/testFileRemote" ,
361332 shouldExistInLocal : true ,
362333 shouldExistInRemote : true ,
363334 },
@@ -436,6 +407,9 @@ func createTestFilesAndFolders(local string, remote string) ([]checkedFileOrFold
436407 filesToCheck = append (filesToCheck , removeEquivalent )
437408 }
438409 for _ , f := range foldersToCheck {
410+ if f .path == "testFolder" {
411+ continue
412+ }
439413 removeEquivalent := checkedFileOrFolder {
440414 path : f .path + "_Remove" ,
441415 shouldExistInLocal : f .shouldExistInLocal ,
@@ -449,17 +423,20 @@ func createTestFilesAndFolders(local string, remote string) ([]checkedFileOrFold
449423
450424func removeSomeTestFilesAndFolders (local string , remote string , filesToCheck []checkedFileOrFolder , foldersToCheck []checkedFileOrFolder , removeSuffix string ) ([]checkedFileOrFolder , []checkedFileOrFolder , error ) {
451425
426+ var completeSuffix string
452427 removeIfSuffixMatch := func (path string , f os.FileInfo , err error ) error {
453- if strings .HasSuffix (path , removeSuffix ) {
428+ if strings .HasSuffix (path , completeSuffix ) {
454429 return os .RemoveAll (path )
455430 }
456431 return nil
457432 }
458433
434+ completeSuffix = "Remote" + removeSuffix
459435 err := filepath .Walk (remote , removeIfSuffixMatch )
460436 if err != nil {
461437 return nil , nil , err
462438 }
439+ completeSuffix = "Local" + removeSuffix
463440 err = filepath .Walk (local , removeIfSuffixMatch )
464441 if err != nil {
465442 return nil , nil , err
0 commit comments