@@ -302,47 +302,52 @@ private void synchronizeData(ArrayList<Object> folderAndFiles, OwnCloudClient cl
302302 }
303303
304304 // loop to synchronize every child
305- OCFile remoteFile = null , localFile = null ;
305+ OCFile remoteFile = null , localFile = null , updatedFile = null ;
306+ RemoteFile r ;
306307 for (int i =1 ; i <folderAndFiles .size (); i ++) {
307308 /// new OCFile instance with the data from the server
308- remoteFile = FileStorageUtils .fillOCFile ((RemoteFile )folderAndFiles .get (i ));
309- remoteFile .setParentId (mLocalFolder .getFileId ());
309+ r = (RemoteFile ) folderAndFiles .get (i );
310+ remoteFile = FileStorageUtils .fillOCFile (r );
311+
312+ /// new OCFile instance to merge fresh data from server with local state
313+ updatedFile = FileStorageUtils .fillOCFile (r );
314+ updatedFile .setParentId (mLocalFolder .getFileId ());
310315
311316 /// retrieve local data for the read file
312317 // localFile = mStorageManager.getFileByPath(remoteFile.getRemotePath());
313318 localFile = localFilesMap .remove (remoteFile .getRemotePath ());
314319
315- /// add to the remoteFile (the new one) data about LOCAL STATE (not existing in server)
316- remoteFile .setLastSyncDateForProperties (mCurrentSyncTime );
320+ /// add to updatedFile data about LOCAL STATE (not existing in server)
321+ updatedFile .setLastSyncDateForProperties (mCurrentSyncTime );
317322 if (localFile != null ) {
318- // some properties of local state are kept unmodified
319- remoteFile .setFileId (localFile .getFileId ());
320- remoteFile .setFavorite (localFile .isFavorite ());
321- remoteFile .setLastSyncDateForData (localFile .getLastSyncDateForData ());
322- remoteFile .setModificationTimestampAtLastSyncForData (
323+ updatedFile .setFileId (localFile .getFileId ());
324+ updatedFile .setFavorite (localFile .isFavorite ());
325+ updatedFile .setLastSyncDateForData (localFile .getLastSyncDateForData ());
326+ updatedFile .setModificationTimestampAtLastSyncForData (
323327 localFile .getModificationTimestampAtLastSyncForData ()
324328 );
325- remoteFile .setStoragePath (localFile .getStoragePath ());
326- // eTag will not be updated unless contents are synchronized
327- remoteFile .setEtag (localFile .getEtag ());
328- if (remoteFile .isFolder ()) {
329- remoteFile .setFileLength (localFile .getFileLength ());
329+ updatedFile .setStoragePath (localFile .getStoragePath ());
330+ // eTag will not be updated unless file CONTENTS are synchronized
331+ updatedFile .setEtag (localFile .getEtag ());
332+ if (updatedFile .isFolder ()) {
333+ updatedFile .setFileLength (localFile .getFileLength ());
330334 // TODO move operations about size of folders to FileContentProvider
331335 } else if (mRemoteFolderChanged && remoteFile .isImage () &&
332336 remoteFile .getModificationTimestamp () !=
333337 localFile .getModificationTimestamp ()) {
334- remoteFile .setNeedsUpdateThumbnail (true );
338+ updatedFile .setNeedsUpdateThumbnail (true );
335339 Log .d (TAG , "Image " + remoteFile .getFileName () + " updated on the server" );
336340 }
337- remoteFile .setPublicLink (localFile .getPublicLink ());
338- remoteFile .setShareByLink (localFile .isShareByLink ());
341+ updatedFile .setPublicLink (localFile .getPublicLink ());
342+ updatedFile .setShareByLink (localFile .isShareByLink ());
343+ updatedFile .setInConflict (localFile .isInConflict ());
339344 } else {
340- // remote eTag will not be updated unless contents are synchronized
341- remoteFile .setEtag ("" );
345+ // remote eTag will not be updated unless file CONTENTS are synchronized
346+ updatedFile .setEtag ("" );
342347 }
343348
344349 /// check and fix, if needed, local storage path
345- searchForLocalFileInDefaultPath (remoteFile );
350+ searchForLocalFileInDefaultPath (updatedFile );
346351
347352 /// classify file to sync/download contents later
348353 if (remoteFile .isFolder ()) {
@@ -367,7 +372,7 @@ private void synchronizeData(ArrayList<Object> folderAndFiles, OwnCloudClient cl
367372
368373 }
369374
370- updatedFiles .add (remoteFile );
375+ updatedFiles .add (updatedFile );
371376 }
372377
373378 // save updated contents in local database
@@ -399,7 +404,7 @@ private void prepareOpsFromLocalKnowledge() throws OperationCancelledException {
399404 /// this should result in direct upload of files that were locally modified
400405 SynchronizeFileOperation operation = new SynchronizeFileOperation (
401406 child ,
402- child , // cheating with the remote file to get an upadte to server; to refactor
407+ ( child . isInConflict () ? null : child ),
403408 mAccount ,
404409 true ,
405410 mContext
0 commit comments