Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -1285,25 +1285,6 @@ private void resetShareFlagsInFolder(OCFile folder) {
}
}

private void resetShareFlagInAFile(String filePath) {
ContentValues contentValues = new ContentValues();
contentValues.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, Boolean.FALSE);
contentValues.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, Boolean.FALSE);
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + " = ?";
String[] whereArgs = new String[]{user.getAccountName(), filePath};

if (getContentResolver() != null) {
getContentResolver().update(ProviderTableMeta.CONTENT_URI, contentValues, where, whereArgs);

} else {
try {
getContentProviderClient().update(ProviderTableMeta.CONTENT_URI, contentValues, where, whereArgs);
} catch (RemoteException e) {
Log_OC.e(TAG, "Exception in resetShareFlagsInFolder " + e.getMessage(), e);
}
}
}

@VisibleForTesting
public void cleanShares() {
String where = ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
Expand Down Expand Up @@ -1384,59 +1365,6 @@ public void removeShare(OCShare share) {
}
}

public void saveSharesDB(List<OCShare> shares) {
ArrayList<ContentProviderOperation> operations = new ArrayList<>();

// Reset flags & Remove shares for this files
String filePath = "";
for (OCShare share : shares) {
if (!filePath.equals(share.getPath())) {
filePath = share.getPath();
resetShareFlagInAFile(filePath);
operations = prepareRemoveSharesInFile(filePath, operations);
}
}

// Add operations to insert shares
operations = prepareInsertShares(shares, operations);

// apply operations in batch
if (operations.size() > 0) {
Log_OC.d(TAG, String.format(Locale.ENGLISH, SENDING_TO_FILECONTENTPROVIDER_MSG, operations.size()));
try {
if (getContentResolver() != null) {
getContentResolver().applyBatch(MainApp.getAuthority(), operations);

} else {
getContentProviderClient().applyBatch(operations);
}

} catch (OperationApplicationException | RemoteException e) {
Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage(), e);
}
}
}

public void removeSharesForFile(String remotePath) {
resetShareFlagInAFile(remotePath);
ArrayList<ContentProviderOperation> operations = prepareRemoveSharesInFile(remotePath, new ArrayList<>());
// apply operations in batch
if (operations.size() > 0) {
Log_OC.d(TAG, String.format(Locale.ENGLISH, SENDING_TO_FILECONTENTPROVIDER_MSG, operations.size()));
try {
if (getContentResolver() != null) {
getContentResolver().applyBatch(MainApp.getAuthority(), operations);

} else {
getContentProviderClient().applyBatch(operations);
}

} catch (OperationApplicationException | RemoteException e) {
Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage(), e);
}
}
}

// TOOD check if shares can be null
public void saveSharesInFolder(ArrayList<OCShare> shares, OCFile folder) {
resetShareFlagsInFolder(folder);
Expand Down Expand Up @@ -1510,24 +1438,6 @@ private ArrayList<ContentProviderOperation> prepareRemoveSharesInFolder(
return preparedOperations;
}

private ArrayList<ContentProviderOperation> prepareRemoveSharesInFile(
String filePath, ArrayList<ContentProviderOperation> preparedOperations) {

String where = ProviderTableMeta.OCSHARES_PATH + AND
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + " = ?";
String[] whereArgs = new String[]{filePath, user.getAccountName()};

preparedOperations.add(
ContentProviderOperation
.newDelete(ProviderTableMeta.CONTENT_URI_SHARE)
.withSelection(where, whereArgs)
.build()
);

return preparedOperations;

}

public List<OCShare> getSharesWithForAFile(String filePath, String accountName) {
String selection = ProviderTableMeta.OCSHARES_PATH + AND
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + AND
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.operations.CreateShareViaLinkOperation;
import com.owncloud.android.operations.CreateShareWithShareeOperation;
import com.owncloud.android.operations.GetSharesForFileOperation;
import com.owncloud.android.operations.SynchronizeFileOperation;
import com.owncloud.android.operations.SynchronizeFolderOperation;
import com.owncloud.android.operations.UnshareOperation;
Expand Down Expand Up @@ -391,16 +390,6 @@ public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationRe
} else if (operation instanceof SynchronizeFileOperation) {
onSynchronizeFileOperationFinish((SynchronizeFileOperation) operation, result);

} else if (operation instanceof GetSharesForFileOperation) {
if (result.isSuccess() || result.getCode() == ResultCode.SHARE_NOT_FOUND) {
updateFileFromDB();

} else {
DisplayUtils.showSnackMessage(this,
ErrorMessageAdapter.getErrorCauseMessage(result,
operation,
getResources()));
}
}

if (operation instanceof CreateShareViaLinkOperation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
import com.owncloud.android.lib.resources.files.model.RemoteFile;
import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.operations.GetSharesForFileOperation;
import com.owncloud.android.ui.fragment.FileDetailSharingFragment;
import com.owncloud.android.ui.fragment.FileDetailsSharingProcessFragment;
import com.owncloud.android.utils.DisplayUtils;
Expand Down Expand Up @@ -160,11 +159,7 @@ protected void doShareWith(String shareeName, ShareType shareType) {
public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
super.onRemoteOperationFinish(operation, result);

if (result.isSuccess() ||
(operation instanceof GetSharesForFileOperation &&
result.getCode() == RemoteOperationResult.ResultCode.SHARE_NOT_FOUND
)
) {
if (result.isSuccess()) {
Log_OC.d(TAG, "Refreshing view on successful operation or finished refresh");
refreshSharesFromStorageManager();
}
Expand Down