@@ -101,19 +101,13 @@ func (d *downstream) mainLoop() error {
101101
102102 for {
103103 removeFiles := d .cloneFileMap ()
104- removeFilesLen := len (removeFiles )
105104
106105 // Check for changes remotely
107106 createFiles , err := d .collectChanges (removeFiles )
108107 if err != nil {
109108 return errors .Trace (err )
110109 }
111110
112- // There is an issue with collect changes, hence we return an error
113- if removeFilesLen == len (removeFiles ) {
114- return errors .New ("Sync cannot execute find command remotely" )
115- }
116-
117111 amountChanges := len (createFiles ) + len (removeFiles )
118112 if lastAmountChanges > 0 && amountChanges == lastAmountChanges {
119113 err = d .applyChanges (createFiles , removeFiles )
@@ -157,6 +151,7 @@ func (d *downstream) cloneFileMap() map[string]*fileInformation {
157151
158152func (d * downstream ) collectChanges (removeFiles map [string ]* fileInformation ) ([]* fileInformation , error ) {
159153 createFiles := make ([]* fileInformation , 0 , 128 )
154+ destPathFound := false
160155
161156 // Write find command to stdin pipe
162157 cmd := getFindCommand (d .config .DestPath )
@@ -189,7 +184,7 @@ func (d *downstream) collectChanges(removeFiles map[string]*fileInformation) ([]
189184 return nil , errors .Trace (err )
190185 }
191186
192- done , overlap , err = d .parseLines (string (buf ), overlap , & createFiles , removeFiles )
187+ done , overlap , err = d .parseLines (string (buf ), overlap , & createFiles , removeFiles , & destPathFound )
193188 if err != nil {
194189 if _ , ok := err .(parsingError ); ok {
195190 time .Sleep (time .Second * 4 )
@@ -201,10 +196,14 @@ func (d *downstream) collectChanges(removeFiles map[string]*fileInformation) ([]
201196 }
202197 }
203198
199+ if destPathFound == false {
200+ return nil , errors .New ("DestPath not found, find command did not execute correctly" )
201+ }
202+
204203 return createFiles , nil
205204}
206205
207- func (d * downstream ) parseLines (buffer , overlap string , createFiles * []* fileInformation , removeFiles map [string ]* fileInformation ) (bool , string , error ) {
206+ func (d * downstream ) parseLines (buffer , overlap string , createFiles * []* fileInformation , removeFiles map [string ]* fileInformation , destPathFound * bool ) (bool , string , error ) {
208207 lines := strings .Split (buffer , "\n " )
209208
210209 for index , element := range lines {
@@ -229,7 +228,10 @@ func (d *downstream) parseLines(buffer, overlap string, createFiles *[]*fileInfo
229228 msg : "Parsing Error" ,
230229 }
231230 } else if line != "" {
232- err := d .evaluateFile (line , createFiles , removeFiles )
231+ destPath , err := d .evaluateFile (line , createFiles , removeFiles )
232+ if destPath {
233+ * destPathFound = destPath
234+ }
233235
234236 if err != nil {
235237 return true , "" , errors .Trace (err )
@@ -240,20 +242,20 @@ func (d *downstream) parseLines(buffer, overlap string, createFiles *[]*fileInfo
240242 return false , overlap , nil
241243}
242244
243- func (d * downstream ) evaluateFile (fileline string , createFiles * []* fileInformation , removeFiles map [string ]* fileInformation ) error {
245+ func (d * downstream ) evaluateFile (fileline string , createFiles * []* fileInformation , removeFiles map [string ]* fileInformation ) ( bool , error ) {
244246 d .config .fileIndex .fileMapMutex .Lock ()
245247 defer d .config .fileIndex .fileMapMutex .Unlock ()
246248
247249 fileInformation , err := parseFileInformation (fileline , d .config .DestPath )
248250
249251 // Error parsing line
250252 if err != nil {
251- return errors .Trace (err )
253+ return false , errors .Trace (err )
252254 }
253255
254256 // No file found
255257 if fileInformation == nil {
256- return nil
258+ return true , nil
257259 }
258260
259261 // File found don't delete it
@@ -277,7 +279,7 @@ func (d *downstream) evaluateFile(fileline string, createFiles *[]*fileInformati
277279 * createFiles = append (* createFiles , fileInformation )
278280 }
279281
280- return nil
282+ return false , nil
281283}
282284
283285func (d * downstream ) applyChanges (createFiles []* fileInformation , removeFiles map [string ]* fileInformation ) error {
0 commit comments