|
@@ -92,7 +92,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
|
|
/**
|
|
|
* Access to the local database
|
|
|
*/
|
|
|
- private final FileDataStorageManager mStorageManager;
|
|
|
+ private final FileDataStorageManager fileDataStorageManager;
|
|
|
|
|
|
/**
|
|
|
* Account where the file to synchronize belongs
|
|
@@ -171,7 +171,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
|
|
mLocalFolder = folder;
|
|
|
mCurrentSyncTime = currentSyncTime;
|
|
|
mSyncFullAccount = syncFullAccount;
|
|
|
- mStorageManager = dataStorageManager;
|
|
|
+ fileDataStorageManager = dataStorageManager;
|
|
|
this.user = user;
|
|
|
mContext = context;
|
|
|
mForgottenLocalFiles = new HashMap<>();
|
|
@@ -192,7 +192,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
|
|
mLocalFolder = folder;
|
|
|
mCurrentSyncTime = currentSyncTime;
|
|
|
mSyncFullAccount = syncFullAccount;
|
|
|
- mStorageManager = dataStorageManager;
|
|
|
+ fileDataStorageManager = dataStorageManager;
|
|
|
this.user = user;
|
|
|
mContext = context;
|
|
|
mForgottenLocalFiles = new HashMap<>();
|
|
@@ -248,7 +248,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
|
|
// TODO catch IllegalStateException, show properly to user
|
|
|
result = fetchAndSyncRemoteFolder(client);
|
|
|
} else {
|
|
|
- mChildren = mStorageManager.getFolderContent(mLocalFolder, false);
|
|
|
+ mChildren = fileDataStorageManager.getFolderContent(mLocalFolder, false);
|
|
|
}
|
|
|
|
|
|
if (result.isSuccess()) {
|
|
@@ -259,15 +259,13 @@ public class RefreshFolderOperation extends RemoteOperation {
|
|
|
}
|
|
|
|
|
|
mLocalFolder.setLastSyncDateForData(System.currentTimeMillis());
|
|
|
- mStorageManager.saveFile(mLocalFolder);
|
|
|
+ fileDataStorageManager.saveFile(mLocalFolder);
|
|
|
}
|
|
|
|
|
|
checkFolderConflictData(result);
|
|
|
|
|
|
if (!mSyncFullAccount && mRemoteFolderChanged) {
|
|
|
- sendLocalBroadcast(
|
|
|
- EVENT_SINGLE_FOLDER_CONTENTS_SYNCED, mLocalFolder.getRemotePath(), result
|
|
|
- );
|
|
|
+ sendLocalBroadcast(EVENT_SINGLE_FOLDER_CONTENTS_SYNCED, mLocalFolder.getRemotePath(), result);
|
|
|
}
|
|
|
|
|
|
if (result.isSuccess() && !mSyncFullAccount && !mOnlyFileMetadata) {
|
|
@@ -275,9 +273,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
|
|
}
|
|
|
|
|
|
if (!mSyncFullAccount) {
|
|
|
- sendLocalBroadcast(
|
|
|
- EVENT_SINGLE_FOLDER_SHARES_SYNCED, mLocalFolder.getRemotePath(), result
|
|
|
- );
|
|
|
+ sendLocalBroadcast(EVENT_SINGLE_FOLDER_SHARES_SYNCED, mLocalFolder.getRemotePath(), result);
|
|
|
}
|
|
|
|
|
|
return result;
|
|
@@ -286,9 +282,11 @@ public class RefreshFolderOperation extends RemoteOperation {
|
|
|
private static HashMap<String, String> lastConflictData = new HashMap<>();
|
|
|
|
|
|
private void checkFolderConflictData(RemoteOperationResult result) {
|
|
|
- var offlineOperations = mStorageManager.offlineOperationDao.getAll();
|
|
|
- var conflictData = RemoteOperationResultExtensionsKt.getConflictedRemoteIdsWithOfflineOperations(result, offlineOperations);
|
|
|
- if (conflictData != null && !conflictData.isEmpty() && !conflictData.equals(lastConflictData)) {
|
|
|
+ var offlineOperations = fileDataStorageManager.offlineOperationDao.getAll();
|
|
|
+ if (offlineOperations.isEmpty()) return;
|
|
|
+
|
|
|
+ var conflictData = RemoteOperationResultExtensionsKt.getConflictedRemoteIdsWithOfflineOperations(result, offlineOperations, fileDataStorageManager);
|
|
|
+ if (conflictData != null && !conflictData.equals(lastConflictData)) {
|
|
|
lastConflictData = new HashMap<>(conflictData);
|
|
|
sendFolderSyncConflictEventBroadcast(conflictData);
|
|
|
}
|
|
@@ -313,7 +311,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
|
|
try {
|
|
|
NextcloudClient nextcloudClient = OwnCloudClientFactory.createNextcloudClient(user, mContext);
|
|
|
|
|
|
- RemoteOperationResult<UserInfo> result = new GetUserProfileOperation(mStorageManager).execute(nextcloudClient);
|
|
|
+ RemoteOperationResult<UserInfo> result = new GetUserProfileOperation(fileDataStorageManager).execute(nextcloudClient);
|
|
|
if (!result.isSuccess()) {
|
|
|
Log_OC.w(TAG, "Couldn't update user profile from server");
|
|
|
} else {
|
|
@@ -329,9 +327,9 @@ public class RefreshFolderOperation extends RemoteOperation {
|
|
|
String oldDirectEditingEtag = arbitraryDataProvider.getValue(user,
|
|
|
ArbitraryDataProvider.DIRECT_EDITING_ETAG);
|
|
|
|
|
|
- RemoteOperationResult result = new GetCapabilitiesOperation(mStorageManager).execute(mContext);
|
|
|
+ RemoteOperationResult result = new GetCapabilitiesOperation(fileDataStorageManager).execute(mContext);
|
|
|
if (result.isSuccess()) {
|
|
|
- String newDirectEditingEtag = mStorageManager.getCapability(user.getAccountName()).getDirectEditingEtag();
|
|
|
+ String newDirectEditingEtag = fileDataStorageManager.getCapability(user.getAccountName()).getDirectEditingEtag();
|
|
|
|
|
|
if (!oldDirectEditingEtag.equalsIgnoreCase(newDirectEditingEtag)) {
|
|
|
updateDirectEditing(arbitraryDataProvider, newDirectEditingEtag);
|
|
@@ -450,13 +448,13 @@ public class RefreshFolderOperation extends RemoteOperation {
|
|
|
}
|
|
|
|
|
|
private void removeLocalFolder() {
|
|
|
- if (mStorageManager.fileExists(mLocalFolder.getFileId())) {
|
|
|
+ if (fileDataStorageManager.fileExists(mLocalFolder.getFileId())) {
|
|
|
String currentSavePath = FileStorageUtils.getSavePath(user.getAccountName());
|
|
|
- mStorageManager.removeFolder(
|
|
|
+ fileDataStorageManager.removeFolder(
|
|
|
mLocalFolder,
|
|
|
true,
|
|
|
mLocalFolder.isDown() && mLocalFolder.getStoragePath().startsWith(currentSavePath)
|
|
|
- );
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -471,7 +469,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
|
|
*/
|
|
|
private void synchronizeData(List<Object> folderAndFiles) {
|
|
|
// get 'fresh data' from the database
|
|
|
- mLocalFolder = mStorageManager.getFileByPath(mLocalFolder.getRemotePath());
|
|
|
+ mLocalFolder = fileDataStorageManager.getFileByPath(mLocalFolder.getRemotePath());
|
|
|
|
|
|
if (mLocalFolder == null) {
|
|
|
Log_OC.d(TAG,"mLocalFolder cannot be null");
|
|
@@ -489,7 +487,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
|
|
mFilesToSyncContents.clear();
|
|
|
|
|
|
// if local folder is encrypted, download fresh metadata
|
|
|
- boolean encryptedAncestor = FileStorageUtils.checkEncryptionStatus(mLocalFolder, mStorageManager);
|
|
|
+ boolean encryptedAncestor = FileStorageUtils.checkEncryptionStatus(mLocalFolder, fileDataStorageManager);
|
|
|
mLocalFolder.setEncrypted(encryptedAncestor);
|
|
|
|
|
|
// update permission
|
|
@@ -525,11 +523,11 @@ public class RefreshFolderOperation extends RemoteOperation {
|
|
|
if (object instanceof DecryptedFolderMetadataFileV1) {
|
|
|
e2EVersion = E2EVersion.V1_2;
|
|
|
localFilesMap = prefillLocalFilesMap((DecryptedFolderMetadataFileV1) object,
|
|
|
- mStorageManager.getFolderContent(mLocalFolder, false));
|
|
|
+ fileDataStorageManager.getFolderContent(mLocalFolder, false));
|
|
|
} else {
|
|
|
e2EVersion = E2EVersion.V2_0;
|
|
|
localFilesMap = prefillLocalFilesMap((DecryptedFolderMetadataFile) object,
|
|
|
- mStorageManager.getFolderContent(mLocalFolder, false));
|
|
|
+ fileDataStorageManager.getFolderContent(mLocalFolder, false));
|
|
|
|
|
|
// update counter
|
|
|
if (object != null) {
|
|
@@ -557,7 +555,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
|
|
|
|
|
// TODO better implementation is needed
|
|
|
if (localFile == null) {
|
|
|
- localFile = mStorageManager.getFileByPath(updatedFile.getRemotePath());
|
|
|
+ localFile = fileDataStorageManager.getFileByPath(updatedFile.getRemotePath());
|
|
|
}
|
|
|
|
|
|
// add to updatedFile data about LOCAL STATE (not existing in server)
|
|
@@ -576,11 +574,11 @@ public class RefreshFolderOperation extends RemoteOperation {
|
|
|
|
|
|
// update file name for encrypted files
|
|
|
if (e2EVersion == E2EVersion.V1_2) {
|
|
|
- updateFileNameForEncryptedFileV1(mStorageManager,
|
|
|
+ updateFileNameForEncryptedFileV1(fileDataStorageManager,
|
|
|
(DecryptedFolderMetadataFileV1) object,
|
|
|
updatedFile);
|
|
|
} else {
|
|
|
- updateFileNameForEncryptedFile(mStorageManager,
|
|
|
+ updateFileNameForEncryptedFile(fileDataStorageManager,
|
|
|
(DecryptedFolderMetadataFile) object,
|
|
|
updatedFile);
|
|
|
if (localFile != null) {
|
|
@@ -599,15 +597,15 @@ public class RefreshFolderOperation extends RemoteOperation {
|
|
|
// save updated contents in local database
|
|
|
// update file name for encrypted files
|
|
|
if (e2EVersion == E2EVersion.V1_2) {
|
|
|
- updateFileNameForEncryptedFileV1(mStorageManager,
|
|
|
+ updateFileNameForEncryptedFileV1(fileDataStorageManager,
|
|
|
(DecryptedFolderMetadataFileV1) object,
|
|
|
mLocalFolder);
|
|
|
} else {
|
|
|
- updateFileNameForEncryptedFile(mStorageManager,
|
|
|
+ updateFileNameForEncryptedFile(fileDataStorageManager,
|
|
|
(DecryptedFolderMetadataFile) object,
|
|
|
mLocalFolder);
|
|
|
}
|
|
|
- mStorageManager.saveFolder(remoteFolder, updatedFiles, localFilesMap.values());
|
|
|
+ fileDataStorageManager.saveFolder(remoteFolder, updatedFiles, localFilesMap.values());
|
|
|
|
|
|
mChildren = updatedFiles;
|
|
|
}
|
|
@@ -837,7 +835,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
|
|
shares.add(share);
|
|
|
}
|
|
|
}
|
|
|
- mStorageManager.saveSharesInFolder(shares, mLocalFolder);
|
|
|
+ fileDataStorageManager.saveSharesInFolder(shares, mLocalFolder);
|
|
|
}
|
|
|
|
|
|
return result;
|