X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/8d493de0ea590d669dadad7f2fe6d22fd72f9cb5..ebbc1793e23f67dc7aa2214a542fa2c037fcf4c2:/src/com/owncloud/android/operations/UnshareLinkOperation.java?ds=sidebyside diff --git a/src/com/owncloud/android/operations/UnshareLinkOperation.java b/src/com/owncloud/android/operations/UnshareLinkOperation.java index c588ec1a..ad23427f 100644 --- a/src/com/owncloud/android/operations/UnshareLinkOperation.java +++ b/src/com/owncloud/android/operations/UnshareLinkOperation.java @@ -22,7 +22,7 @@ import com.owncloud.android.lib.network.OwnCloudClient; import com.owncloud.android.lib.operations.common.OCShare; import com.owncloud.android.lib.operations.common.RemoteOperationResult; import com.owncloud.android.lib.operations.common.RemoteOperationResult.ResultCode; -import com.owncloud.android.lib.operations.remote.UnshareLinkRemoteOperation; +import com.owncloud.android.lib.operations.remote.RemoveRemoteShareOperation; import com.owncloud.android.operations.common.SyncOperation; import com.owncloud.android.utils.Log_OC; @@ -47,13 +47,17 @@ public class UnshareLinkOperation extends SyncOperation { RemoteOperationResult result = null; // Get Share for a file - OCShare share = getStorageManager().getShareByPath(mFile.getRemotePath()); + String path = mFile.getRemotePath(); + if (mFile.isFolder()) { + path = path.substring(0, path.length()-1); // Remove last / + } + OCShare share = getStorageManager().getShareByPath(path); if (share != null) { - UnshareLinkRemoteOperation operation = new UnshareLinkRemoteOperation((int) share.getIdRemoteShared()); + RemoveRemoteShareOperation operation = new RemoveRemoteShareOperation((int) share.getIdRemoteShared()); result = operation.execute(client); - if (result.isSuccess()) { + if (result.isSuccess() || result.getCode() == ResultCode.SHARE_NOT_FOUND) { Log_OC.d(TAG, "Share id = " + share.getIdRemoteShared() + " deleted"); mFile.setShareByLink(false); @@ -61,9 +65,13 @@ public class UnshareLinkOperation extends SyncOperation { getStorageManager().saveFile(mFile); getStorageManager().removeShare(share); - } + if (result.getCode() == ResultCode.SHARE_NOT_FOUND) { + result = new RemoteOperationResult(ResultCode.OK); + } + } + } else { - result = new RemoteOperationResult(ResultCode.FILE_NOT_FOUND); + result = new RemoteOperationResult(ResultCode.SHARE_NOT_FOUND); } return result;