From: masensio Date: Thu, 5 Jun 2014 15:11:59 +0000 (+0200) Subject: Review the behaviour when delete locally a keep_in_sync_file.Clear etag to force... X-Git-Tag: oc-android-1.7.0_signed~286^2~1 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/a468ae6a2da00fe0a685abbf23d77eaa5fb0a13e?ds=inline;hp=-c Review the behaviour when delete locally a keep_in_sync_file.Clear etag to force to download keep_in_sync files --- a468ae6a2da00fe0a685abbf23d77eaa5fb0a13e diff --git a/src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java b/src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java index 9020dd0f..8039e522 100644 --- a/src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java +++ b/src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java @@ -24,11 +24,14 @@ 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; import com.owncloud.android.ui.activity.ComponentsGetter; import com.owncloud.android.ui.dialog.ConfirmationDialogFragment.ConfirmationDialogFragmentListener; +import com.owncloud.android.utils.Log_OC; import android.app.Dialog; import android.os.Bundle; @@ -98,12 +101,41 @@ 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); + Log_OC.d("RemoveFileDialogFragment", "Parent etag= |" + folder.getEtag() + "|"); + } } @Override diff --git a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java index 44f76736..ae8bb9e7 100644 --- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -442,10 +442,11 @@ public class OCFileListFragment extends ExtendedListFragment { if (mFile != null) { // Refresh mFile mFile = mContainerActivity.getStorageManager().getFileById(mFile.getFileId()); - + listDirectory(mFile); ((FileDisplayActivity)mContainerActivity).startSyncFolderOperation(mFile); + Log_OC.d(TAG, "Parent etag= |" + mFile.getEtag() + "|"); } }