use of at.bitfire.dav4jvm.exception.DavException in project android by owncloud.
the class FileSyncAdapter method synchronizeFolder.
/**
* Synchronizes the list of files contained in a folder identified with its remote path.
* <p>
* Fetches the list and properties of the files contained in the given folder, including their
* properties, and updates the local database with them.
* <p>
* Enters in the child folders to synchronize their contents also, following a recursive
* depth first strategy.
*
* @param folder Folder to synchronize.
* @param pushOnly When 'true', it's assumed that the folder did not change in the
* server, so data will not be fetched. Only local changes of
* available offline files will be pushed.
*/
private void synchronizeFolder(OCFile folder, boolean pushOnly) {
if (mFailedResultsCounter > MAX_FAILED_RESULTS || isFinisher(mLastFailedResult)) {
return;
}
// folder synchronization
SynchronizeFolderOperation synchFolderOp = new SynchronizeFolderOperation(getContext(), folder.getRemotePath(), getAccount(), mCurrentSyncTime, pushOnly, // sync full account
true, // sync regular files in folder
false);
RemoteOperationResult result;
boolean repeat;
do {
repeat = false;
result = synchFolderOp.execute(getClient(), getStorageManager());
} while (repeat);
// synchronized folder -> notice to UI - ALWAYS, although !result.isSuccess
sendLocalBroadcast(EVENT_FULL_SYNC_FOLDER_CONTENTS_SYNCED, folder.getRemotePath(), result);
// check the result of synchronizing the folder
if (result.isSuccess() || result.getCode() == ResultCode.SYNC_CONFLICT) {
if (result.getCode() == ResultCode.SYNC_CONFLICT) {
mConflictsFound += synchFolderOp.getConflictsFound();
mFailsInFavouritesFound += synchFolderOp.getFailsInFileSyncsFound();
}
if (result.isSuccess()) {
// synchronize children folders
List<Pair<OCFile, Boolean>> children = synchFolderOp.getFoldersToVisit();
// beware of the 'hidden' recursion here!
syncSubfolders(children);
}
} else if (result.getCode() != ResultCode.FILE_NOT_FOUND) {
// in failures, the statistics for the global result are updated
if (RemoteOperationResult.ResultCode.UNAUTHORIZED.equals(result.getCode())) {
mSyncResult.stats.numAuthExceptions++;
} else if (result.getException() instanceof DavException) {
mSyncResult.stats.numParseExceptions++;
} else if (result.getException() instanceof IOException) {
mSyncResult.stats.numIoExceptions++;
}
mFailedResultsCounter++;
mLastFailedResult = result;
}
// else, ResultCode.FILE_NOT_FOUND is ignored, remote folder was
// removed from other thread or other client during the synchronization,
// before this thread fetched its contents
}
Aggregations