|
@@ -302,47 +302,52 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
|
}
|
|
}
|
|
|
|
|
|
// loop to synchronize every child
|
|
// loop to synchronize every child
|
|
- OCFile remoteFile = null, localFile = null;
|
|
|
|
|
|
+ OCFile remoteFile = null, localFile = null, updatedFile = null;
|
|
|
|
+ RemoteFile r;
|
|
for (int i=1; i<folderAndFiles.size(); i++) {
|
|
for (int i=1; i<folderAndFiles.size(); i++) {
|
|
/// new OCFile instance with the data from the server
|
|
/// new OCFile instance with the data from the server
|
|
- remoteFile = FileStorageUtils.fillOCFile((RemoteFile)folderAndFiles.get(i));
|
|
|
|
- remoteFile.setParentId(mLocalFolder.getFileId());
|
|
|
|
|
|
+ r = (RemoteFile) folderAndFiles.get(i);
|
|
|
|
+ remoteFile = FileStorageUtils.fillOCFile(r);
|
|
|
|
+
|
|
|
|
+ /// new OCFile instance to merge fresh data from server with local state
|
|
|
|
+ updatedFile = FileStorageUtils.fillOCFile(r);
|
|
|
|
+ updatedFile.setParentId(mLocalFolder.getFileId());
|
|
|
|
|
|
/// retrieve local data for the read file
|
|
/// retrieve local data for the read file
|
|
// localFile = mStorageManager.getFileByPath(remoteFile.getRemotePath());
|
|
// localFile = mStorageManager.getFileByPath(remoteFile.getRemotePath());
|
|
localFile = localFilesMap.remove(remoteFile.getRemotePath());
|
|
localFile = localFilesMap.remove(remoteFile.getRemotePath());
|
|
|
|
|
|
- /// add to the remoteFile (the new one) data about LOCAL STATE (not existing in server)
|
|
|
|
- remoteFile.setLastSyncDateForProperties(mCurrentSyncTime);
|
|
|
|
|
|
+ /// add to updatedFile data about LOCAL STATE (not existing in server)
|
|
|
|
+ updatedFile.setLastSyncDateForProperties(mCurrentSyncTime);
|
|
if (localFile != null) {
|
|
if (localFile != null) {
|
|
- // some properties of local state are kept unmodified
|
|
|
|
- remoteFile.setFileId(localFile.getFileId());
|
|
|
|
- remoteFile.setFavorite(localFile.isFavorite());
|
|
|
|
- remoteFile.setLastSyncDateForData(localFile.getLastSyncDateForData());
|
|
|
|
- remoteFile.setModificationTimestampAtLastSyncForData(
|
|
|
|
|
|
+ updatedFile.setFileId(localFile.getFileId());
|
|
|
|
+ updatedFile.setFavorite(localFile.isFavorite());
|
|
|
|
+ updatedFile.setLastSyncDateForData(localFile.getLastSyncDateForData());
|
|
|
|
+ updatedFile.setModificationTimestampAtLastSyncForData(
|
|
localFile.getModificationTimestampAtLastSyncForData()
|
|
localFile.getModificationTimestampAtLastSyncForData()
|
|
);
|
|
);
|
|
- remoteFile.setStoragePath(localFile.getStoragePath());
|
|
|
|
- // eTag will not be updated unless contents are synchronized
|
|
|
|
- remoteFile.setEtag(localFile.getEtag());
|
|
|
|
- if (remoteFile.isFolder()) {
|
|
|
|
- remoteFile.setFileLength(localFile.getFileLength());
|
|
|
|
|
|
+ updatedFile.setStoragePath(localFile.getStoragePath());
|
|
|
|
+ // eTag will not be updated unless file CONTENTS are synchronized
|
|
|
|
+ updatedFile.setEtag(localFile.getEtag());
|
|
|
|
+ if (updatedFile.isFolder()) {
|
|
|
|
+ updatedFile.setFileLength(localFile.getFileLength());
|
|
// TODO move operations about size of folders to FileContentProvider
|
|
// TODO move operations about size of folders to FileContentProvider
|
|
} else if (mRemoteFolderChanged && remoteFile.isImage() &&
|
|
} else if (mRemoteFolderChanged && remoteFile.isImage() &&
|
|
remoteFile.getModificationTimestamp() !=
|
|
remoteFile.getModificationTimestamp() !=
|
|
localFile.getModificationTimestamp()) {
|
|
localFile.getModificationTimestamp()) {
|
|
- remoteFile.setNeedsUpdateThumbnail(true);
|
|
|
|
|
|
+ updatedFile.setNeedsUpdateThumbnail(true);
|
|
Log.d(TAG, "Image " + remoteFile.getFileName() + " updated on the server");
|
|
Log.d(TAG, "Image " + remoteFile.getFileName() + " updated on the server");
|
|
}
|
|
}
|
|
- remoteFile.setPublicLink(localFile.getPublicLink());
|
|
|
|
- remoteFile.setShareByLink(localFile.isShareByLink());
|
|
|
|
|
|
+ updatedFile.setPublicLink(localFile.getPublicLink());
|
|
|
|
+ updatedFile.setShareByLink(localFile.isShareByLink());
|
|
|
|
+ updatedFile.setInConflict(localFile.isInConflict());
|
|
} else {
|
|
} else {
|
|
- // remote eTag will not be updated unless contents are synchronized
|
|
|
|
- remoteFile.setEtag("");
|
|
|
|
|
|
+ // remote eTag will not be updated unless file CONTENTS are synchronized
|
|
|
|
+ updatedFile.setEtag("");
|
|
}
|
|
}
|
|
|
|
|
|
/// check and fix, if needed, local storage path
|
|
/// check and fix, if needed, local storage path
|
|
- searchForLocalFileInDefaultPath(remoteFile);
|
|
|
|
|
|
+ searchForLocalFileInDefaultPath(updatedFile);
|
|
|
|
|
|
/// classify file to sync/download contents later
|
|
/// classify file to sync/download contents later
|
|
if (remoteFile.isFolder()) {
|
|
if (remoteFile.isFolder()) {
|
|
@@ -367,7 +372,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- updatedFiles.add(remoteFile);
|
|
|
|
|
|
+ updatedFiles.add(updatedFile);
|
|
}
|
|
}
|
|
|
|
|
|
// save updated contents in local database
|
|
// save updated contents in local database
|
|
@@ -399,7 +404,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
|
/// this should result in direct upload of files that were locally modified
|
|
/// this should result in direct upload of files that were locally modified
|
|
SynchronizeFileOperation operation = new SynchronizeFileOperation(
|
|
SynchronizeFileOperation operation = new SynchronizeFileOperation(
|
|
child,
|
|
child,
|
|
- child, // cheating with the remote file to get an upadte to server; to refactor
|
|
|
|
|
|
+ (child.isInConflict() ? null : child),
|
|
mAccount,
|
|
mAccount,
|
|
true,
|
|
true,
|
|
mContext
|
|
mContext
|