X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/9b4d153e90cebad0458585fd77d4235d3f44615e..106a2324e113d997db71f00a63ecda3ad828f098:/src/com/owncloud/android/datamodel/FileDataStorageManager.java diff --git a/src/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/com/owncloud/android/datamodel/FileDataStorageManager.java index 6c88116f..8a14244c 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -1427,6 +1427,30 @@ public class FileDataStorageManager { // updateSharedFiles(sharedFiles); } + public void removeSharesForFile(String remotePath) { + resetShareFlagInAFile(remotePath); + ArrayList operations = new ArrayList(); + operations = prepareRemoveSharesInFile(remotePath, operations); + // apply operations in batch + if (operations.size() > 0) { + Log_OC.d(TAG, "Sending " + operations.size() + " operations to FileContentProvider"); + try { + if (getContentResolver() != null) { + getContentResolver().applyBatch(MainApp.getAuthority(), operations); + + } else { + getContentProviderClient().applyBatch(operations); + } + + } catch (OperationApplicationException e) { + Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage()); + + } catch (RemoteException e) { + Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage()); + } + } + } + public void saveSharesInFolder(ArrayList shares, OCFile folder) { resetShareFlagsInFolder(folder); @@ -1711,18 +1735,33 @@ public class FileDataStorageManager { Log_OC.d(TAG, "checking parents to remove conflict; STARTING with " + parentPath); while (parentPath.length() > 0) { - String where = + String whereForDescencentsInConflict = ProviderTableMeta.FILE_ETAG_IN_CONFLICT + " IS NOT NULL AND " + ProviderTableMeta.FILE_CONTENT_TYPE + " != 'DIR' AND " + ProviderTableMeta.FILE_ACCOUNT_OWNER + " = ? AND " + ProviderTableMeta.FILE_PATH + " LIKE ?"; - Cursor descendentsInConflict = getContentResolver().query( - ProviderTableMeta.CONTENT_URI_FILE, - new String[]{ProviderTableMeta._ID}, - where, - new String[]{mAccount.name, parentPath + "%"}, - null - ); + Cursor descendentsInConflict = null; + if (getContentResolver() != null) { + descendentsInConflict = getContentResolver().query( + ProviderTableMeta.CONTENT_URI_FILE, + new String[]{ProviderTableMeta._ID}, + whereForDescencentsInConflict, + new String[]{mAccount.name, parentPath + "%"}, + null + ); + } else { + try { + descendentsInConflict = getContentProviderClient().query( + ProviderTableMeta.CONTENT_URI_FILE, + new String[]{ProviderTableMeta._ID}, + whereForDescencentsInConflict, + new String[]{mAccount.name, parentPath + "%"}, + null + ); + } catch (RemoteException e) { + Log_OC.e(TAG, "Failed querying for descendents in conflict " + e.getMessage()); + } + } if (descendentsInConflict == null || descendentsInConflict.getCount() == 0) { Log_OC.d(TAG, "NO MORE conflicts in " + parentPath); if (getContentResolver() != null) {