From: David A. Velasco Date: Mon, 9 Jun 2014 06:43:37 +0000 (+0200) Subject: Merge pull request #535 from owncloud/fix_keep_up_to_date_when_sync X-Git-Tag: oc-android-1.7.0_signed~286 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/d152a97a6721113f4fdf50c6524f44b0da3d1112?hp=0d94e2f19992401aa8a6baf4fca10127a06e9ce6 Merge pull request #535 from owncloud/fix_keep_up_to_date_when_sync Fixed update of kept-in-sync files when full account is refreshed --- diff --git a/src/com/owncloud/android/files/FileOperationsHelper.java b/src/com/owncloud/android/files/FileOperationsHelper.java index c473c0f0..841994e9 100644 --- a/src/com/owncloud/android/files/FileOperationsHelper.java +++ b/src/com/owncloud/android/files/FileOperationsHelper.java @@ -253,8 +253,15 @@ public class FileOperationsHelper { FileDownloaderBinder downloaderBinder = mFileActivity.getFileDownloaderBinder(); FileUploaderBinder uploaderBinder = mFileActivity.getFileUploaderBinder(); if (downloaderBinder != null && downloaderBinder.isDownloading(account, file)) { + // Remove etag for parent, if file is a keep_in_sync + if (file.keepInSync()) { + OCFile parent = mFileActivity.getStorageManager().getFileById(file.getParentId()); + parent.setEtag(""); + mFileActivity.getStorageManager().saveFile(parent); + } + downloaderBinder.cancel(account, file); - + } else if (uploaderBinder != null && uploaderBinder.isUploading(account, file)) { uploaderBinder.cancel(account, file); } diff --git a/src/com/owncloud/android/notifications/NotificationBuilderWithProgressBar.java b/src/com/owncloud/android/notifications/NotificationBuilderWithProgressBar.java index 3b52f6e4..63ddf635 100644 --- a/src/com/owncloud/android/notifications/NotificationBuilderWithProgressBar.java +++ b/src/com/owncloud/android/notifications/NotificationBuilderWithProgressBar.java @@ -20,12 +20,8 @@ package com.owncloud.android.notifications; import com.owncloud.android.R; import android.app.Notification; -import android.app.NotificationManager; import android.content.Context; import android.os.Build; -import android.os.Handler; -import android.os.HandlerThread; -import android.os.Process; import android.support.v4.app.NotificationCompat; import android.view.View; import android.widget.RemoteViews; diff --git a/src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java b/src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java index 9020dd0f..a78584ae 100644 --- a/src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java +++ b/src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java @@ -24,6 +24,8 @@ package com.owncloud.android.ui.dialog; * * @author David A. Velasco */ +import java.util.Vector; + import com.owncloud.android.R; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; @@ -98,12 +100,40 @@ implements ConfirmationDialogFragmentListener { } /** - * Performs the removal of the local copy of the taget file + * Performs the removal of the local copy of the target file */ @Override public void onNeutral(String callerTag) { - ((ComponentsGetter)getSherlockActivity()).getFileOperationsHelper() + ComponentsGetter cg = (ComponentsGetter)getSherlockActivity(); + cg.getFileOperationsHelper() .removeFile(mTargetFile, true); + + FileDataStorageManager storageManager = cg.getStorageManager(); + + boolean containsKeepInSync = false; + if (mTargetFile.isFolder()) { + Vector files = storageManager.getFolderContent(mTargetFile); + for(OCFile file: files) { + containsKeepInSync = file.keepInSync() || containsKeepInSync; + + if (containsKeepInSync) + break; + } + } + + // Remove etag for parent, if file is a keep_in_sync + // or is a folder and contains keep_in_sync + if (mTargetFile.keepInSync() || containsKeepInSync) { + OCFile folder = null; + if (mTargetFile.isFolder()) { + folder = mTargetFile; + } else { + folder = storageManager.getFileById(mTargetFile.getParentId()); + } + + folder.setEtag(""); + storageManager.saveFile(folder); + } } @Override diff --git a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java index 23bfe6e9..c53b3781 100644 --- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -440,6 +440,9 @@ public class OCFileListFragment extends ExtendedListFragment { super.onRefresh(); if (mFile != null) { + // Refresh mFile + mFile = mContainerActivity.getStorageManager().getFileById(mFile.getFileId()); + listDirectory(mFile); ((FileDisplayActivity)mContainerActivity).startSyncFolderOperation(mFile);