private void synchronizeData(ArrayList<Object> folderAndFiles,OwnCloudClient client){
  mLocalFolder=mStorageManager.getFileByPath(mLocalFolder.getRemotePath());
  OCFile remoteFolder=FileStorageUtils.fillOCFile((RemoteFile)folderAndFiles.get(0));
  remoteFolder.setParentId(mLocalFolder.getParentId());
  remoteFolder.setFileId(mLocalFolder.getFileId());
  Log_OC.d(TAG,"Remote folder " + mLocalFolder.getRemotePath() + " changed - starting update of local data ");
  List<OCFile> updatedFiles=new Vector<>(folderAndFiles.size() - 1);
  mFilesToSyncContents.clear();
  List<OCFile> localFiles=mStorageManager.getFolderContent(mLocalFolder);
  Map<String,OCFile> localFilesMap=new HashMap<>(localFiles.size());
  for (  OCFile file : localFiles) {
    localFilesMap.put(file.getRemotePath(),file);
  }
  OCFile remoteFile, localFile, updatedFile;
  RemoteFile r;
  for (int i=1; i < folderAndFiles.size(); i++) {
    r=(RemoteFile)folderAndFiles.get(i);
    remoteFile=FileStorageUtils.fillOCFile(r);
    updatedFile=FileStorageUtils.fillOCFile(r);
    updatedFile.setParentId(mLocalFolder.getFileId());
    localFile=localFilesMap.remove(remoteFile.getRemotePath());
    updatedFile.setLastSyncDateForProperties(mCurrentSyncTime);
    if (localFile != null) {
      updatedFile.setFileId(localFile.getFileId());
      updatedFile.setFavorite(localFile.isFavorite());
      updatedFile.setLastSyncDateForData(localFile.getLastSyncDateForData());
      updatedFile.setModificationTimestampAtLastSyncForData(localFile.getModificationTimestampAtLastSyncForData());
      updatedFile.setStoragePath(localFile.getStoragePath());
      updatedFile.setEtag(localFile.getEtag());
      if (updatedFile.isFolder()) {
        updatedFile.setFileLength(localFile.getFileLength());
      }
 else       if (mRemoteFolderChanged && remoteFile.isImage() && remoteFile.getModificationTimestamp() != localFile.getModificationTimestamp()) {
        updatedFile.setNeedsUpdateThumbnail(true);
        Log.d(TAG,"Image " + remoteFile.getFileName() + " updated on the server");
      }
      updatedFile.setPublicLink(localFile.getPublicLink());
      updatedFile.setShareViaLink(localFile.isSharedViaLink());
      updatedFile.setShareWithSharee(localFile.isSharedWithSharee());
      updatedFile.setEtagInConflict(localFile.getEtagInConflict());
    }
 else {
      updatedFile.setEtag("");
    }
    FileStorageUtils.searchForLocalFileInDefaultPath(updatedFile,mAccount);
    if (updatedFile.isFavorite()) {
      SynchronizeFileOperation operation=new SynchronizeFileOperation(localFile,remoteFile,mAccount,true,mContext);
      mFilesToSyncContents.add(operation);
    }
    updatedFiles.add(updatedFile);
  }
  mStorageManager.saveFolder(remoteFolder,updatedFiles,localFilesMap.values());
  mChildren=updatedFiles;
}

private void synchronizeData ( ArrayList < Object > folderAndFiles , OwnCloudClient client ) { mLocalFolder = mStorageManager . getFileByPath ( mLocalFolder . getRemotePath ( ) ) ; OCFile remoteFolder = FileStorageUtils . fillOCFile ( ( RemoteFile ) folderAndFiles . get ( 0 ) ) ; remoteFolder . setParentId ( mLocalFolder . getParentId ( ) ) ; remoteFolder . setFileId ( mLocalFolder . getFileId ( ) ) ; Log_OC . d ( TAG , "Remote folder " + mLocalFolder . getRemotePath ( ) + " changed - starting update of local data " ) ; List < OCFile > updatedFiles = new Vector < > ( folderAndFiles . size ( ) - 1 ) ; mFilesToSyncContents . clear ( ) ; List < OCFile > localFiles = mStorageManager . getFolderContent ( mLocalFolder ) ; Map < String , OCFile > localFilesMap = new HashMap < > ( localFiles . size ( ) ) ; for ( OCFile file : localFiles ) { localFilesMap . put ( file . getRemotePath ( ) , file ) ; } OCFile remoteFile , localFile , updatedFile ; RemoteFile r ; for ( int i = 1 ; i < folderAndFiles . size ( ) ; i ++ ) { r = ( RemoteFile ) folderAndFiles . get ( i ) ; remoteFile = FileStorageUtils . fillOCFile ( r ) ; updatedFile = FileStorageUtils . fillOCFile ( r ) ; updatedFile . setParentId ( mLocalFolder . getFileId ( ) ) ; localFile = localFilesMap . remove ( remoteFile . getRemotePath ( ) ) ; updatedFile . setLastSyncDateForProperties ( mCurrentSyncTime ) ; if ( localFile != null ) { updatedFile . setFileId ( localFile . getFileId ( ) ) ; updatedFile . setFavorite ( localFile . isFavorite ( ) ) ; updatedFile . setLastSyncDateForData ( localFile . getLastSyncDateForData ( ) ) ; updatedFile . setModificationTimestampAtLastSyncForData ( localFile . getModificationTimestampAtLastSyncForData ( ) ) ; updatedFile . setStoragePath ( localFile . getStoragePath ( ) ) ; updatedFile . setEtag ( localFile . getEtag ( ) ) ; if ( updatedFile . isFolder ( ) ) { updatedFile . setFileLength ( localFile . getFileLength ( ) ) ; } else if ( mRemoteFolderChanged && remoteFile . isImage ( ) && remoteFile . getModificationTimestamp ( ) != localFile . getModificationTimestamp ( ) ) { updatedFile . setNeedsUpdateThumbnail ( true ) ; Log . d ( TAG , "Image " + remoteFile . getFileName ( ) + " updated on the server" ) ; } updatedFile . setPublicLink ( localFile . getPublicLink ( ) ) ; updatedFile . setShareViaLink ( localFile . isSharedViaLink ( ) ) ; updatedFile . setShareWithSharee ( localFile . isSharedWithSharee ( ) ) ; updatedFile . setEtagInConflict ( localFile . getEtagInConflict ( ) ) ; } else { updatedFile . setEtag ( "" ) ; } FileStorageUtils . searchForLocalFileInDefaultPath ( updatedFile , mAccount ) ; if ( updatedFile . isFavorite ( ) ) { SynchronizeFileOperation operation = new SynchronizeFileOperation ( localFile , remoteFile , mAccount , true , mContext ) ; mFilesToSyncContents . add ( operation ) ; } updatedFiles . add ( updatedFile ) ; } mStorageManager . saveFolder ( remoteFolder , updatedFiles , localFilesMap . values ( ) ) ; mChildren = updatedFiles ; }
synchronizes the data retrieved from the server about the contents of the target folder with the current data in the local database . grants that mchildren is updated with fresh data after execution .
