X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/0336eced64384c560ea180c63059bf5ac8aecf87..d5625e6cccd85dfb0f9e66a2da8f844341c96e2b:/src/com/owncloud/android/operations/SynchronizeFolderOperation.java diff --git a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java index 68e78578..f5426527 100644 --- a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java +++ b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java @@ -1,5 +1,5 @@ /* ownCloud Android client application - * Copyright (C) 2012-2013 ownCloud Inc. + * Copyright (C) 2012-2014 ownCloud Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, @@ -43,6 +43,7 @@ import com.owncloud.android.lib.resources.shares.OCShare; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; +import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.shares.GetRemoteSharesForFileOperation; import com.owncloud.android.lib.resources.files.FileUtils; import com.owncloud.android.lib.resources.files.ReadRemoteFileOperation; @@ -51,7 +52,6 @@ import com.owncloud.android.lib.resources.files.RemoteFile; import com.owncloud.android.syncadapter.FileSyncAdapter; import com.owncloud.android.utils.FileStorageUtils; -import com.owncloud.android.utils.Log_OC; @@ -109,6 +109,9 @@ public class SynchronizeFolderOperation extends RemoteOperation { /** 'True' means that the remote folder changed from last synchronization and should be fetched */ private boolean mRemoteFolderChanged; + /** 'True' means that Etag will be ignored */ + private boolean mIgnoreETag; + /** * Creates a new instance of {@link SynchronizeFolderOperation}. @@ -126,6 +129,7 @@ public class SynchronizeFolderOperation extends RemoteOperation { long currentSyncTime, boolean syncFullAccount, boolean isShareSupported, + boolean ignoreETag, FileDataStorageManager dataStorageManager, Account account, Context context ) { @@ -138,6 +142,7 @@ public class SynchronizeFolderOperation extends RemoteOperation { mContext = context; mForgottenLocalFiles = new HashMap(); mRemoteFolderChanged = false; + mIgnoreETag = ignoreETag; } @@ -215,7 +220,7 @@ public class SynchronizeFolderOperation extends RemoteOperation { private RemoteOperationResult checkForChanges(OwnCloudClient client) { - mRemoteFolderChanged = false; + mRemoteFolderChanged = true; RemoteOperationResult result = null; String remotePath = null; @@ -227,10 +232,12 @@ public class SynchronizeFolderOperation extends RemoteOperation { result = operation.execute(client); if (result.isSuccess()){ OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0)); - - // check if remote and local folder are different - mRemoteFolderChanged = !(remoteFolder.getEtag().equalsIgnoreCase(mLocalFolder.getEtag())); - + + if (!mIgnoreETag) { + // check if remote and local folder are different + mRemoteFolderChanged = !(remoteFolder.getEtag().equalsIgnoreCase(mLocalFolder.getEtag())); + } + result = new RemoteOperationResult(ResultCode.OK); Log_OC.i(TAG, "Checked " + mAccount.name + remotePath + " : " + (mRemoteFolderChanged ? "changed" : "not changed")); @@ -350,11 +357,11 @@ public class SynchronizeFolderOperation extends RemoteOperation { if (remoteFile.keepInSync()) { SynchronizeFileOperation operation = new SynchronizeFileOperation( localFile, remoteFile, - mStorageManager, - mAccount, + mAccount, true, mContext ); + filesToSyncContents.add(operation); } @@ -382,7 +389,7 @@ public class SynchronizeFolderOperation extends RemoteOperation { private void startContentSynchronizations(List filesToSyncContents, OwnCloudClient client) { RemoteOperationResult contentsResult = null; for (SynchronizeFileOperation op: filesToSyncContents) { - contentsResult = op.execute(client); // returns without waiting for upload or download finishes + contentsResult = op.execute(mStorageManager, mContext); // returns without waiting for upload or download finishes if (!contentsResult.isSuccess()) { if (contentsResult.getCode() == ResultCode.SYNC_CONFLICT) { mConflictsFound++; @@ -416,6 +423,8 @@ public class SynchronizeFolderOperation extends RemoteOperation { file.setMimetype(remote.getMimeType()); file.setModificationTimestamp(remote.getModifiedTimestamp()); file.setEtag(remote.getEtag()); + file.setPermissions(remote.getPermissions()); + file.setRemoteId(remote.getRemoteId()); return file; }