mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
Fixed update of shares database - grant that shares are removed after removing all of them in the server
This commit is contained in:
parent
a9981ac0b4
commit
cea1a76f48
2 changed files with 56 additions and 60 deletions
|
@ -972,9 +972,8 @@ public class FileDataStorageManager {
|
|||
}
|
||||
|
||||
public void saveShares(Collection<OCShare> shares) {
|
||||
cleanShares();
|
||||
if (shares != null) {
|
||||
cleanShares();
|
||||
|
||||
ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>(shares.size());
|
||||
|
||||
// prepare operations to insert or update files to save in the given folder
|
||||
|
@ -1011,32 +1010,33 @@ public class FileDataStorageManager {
|
|||
}
|
||||
|
||||
// apply operations in batch
|
||||
@SuppressWarnings("unused")
|
||||
ContentProviderResult[] results = null;
|
||||
Log_OC.d(TAG, "Sending " + operations.size() + " operations to FileContentProvider");
|
||||
try {
|
||||
if (getContentResolver() != null) {
|
||||
results = getContentResolver().applyBatch(MainApp.getAuthority(), operations);
|
||||
|
||||
} else {
|
||||
results = getContentProviderClient().applyBatch(operations);
|
||||
if (operations.size() > 0) {
|
||||
@SuppressWarnings("unused")
|
||||
ContentProviderResult[] results = null;
|
||||
Log_OC.d(TAG, "Sending " + operations.size() + " operations to FileContentProvider");
|
||||
try {
|
||||
if (getContentResolver() != null) {
|
||||
results = getContentResolver().applyBatch(MainApp.getAuthority(), operations);
|
||||
|
||||
} else {
|
||||
results = 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());
|
||||
}
|
||||
|
||||
} 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 updateSharedFiles(Collection<OCFile> sharedFiles) {
|
||||
cleanSharedFiles();
|
||||
|
||||
if (sharedFiles != null) {
|
||||
cleanSharedFiles();
|
||||
|
||||
ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>(sharedFiles.size());
|
||||
|
||||
// prepare operations to insert or update files to save in the given folder
|
||||
|
@ -1077,24 +1077,25 @@ public class FileDataStorageManager {
|
|||
}
|
||||
|
||||
// apply operations in batch
|
||||
@SuppressWarnings("unused")
|
||||
ContentProviderResult[] results = null;
|
||||
Log_OC.d(TAG, "Sending " + operations.size() + " operations to FileContentProvider");
|
||||
try {
|
||||
if (getContentResolver() != null) {
|
||||
results = getContentResolver().applyBatch(MainApp.getAuthority(), operations);
|
||||
|
||||
} else {
|
||||
results = getContentProviderClient().applyBatch(operations);
|
||||
if (operations.size() > 0) {
|
||||
@SuppressWarnings("unused")
|
||||
ContentProviderResult[] results = null;
|
||||
Log_OC.d(TAG, "Sending " + operations.size() + " operations to FileContentProvider");
|
||||
try {
|
||||
if (getContentResolver() != null) {
|
||||
results = getContentResolver().applyBatch(MainApp.getAuthority(), operations);
|
||||
|
||||
} else {
|
||||
results = 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());
|
||||
}
|
||||
|
||||
} 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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -62,34 +62,29 @@ public class GetSharesOperation extends SyncOperation {
|
|||
}
|
||||
|
||||
private void saveSharesDB(ArrayList<OCShare> shares) {
|
||||
// Save share file
|
||||
getStorageManager().saveShares(shares);
|
||||
|
||||
if (shares.size() > 0) {
|
||||
// Save share file
|
||||
getStorageManager().saveShares(shares);
|
||||
ArrayList<OCFile> sharedFiles = new ArrayList<OCFile>();
|
||||
|
||||
ArrayList<OCFile> sharedFiles = new ArrayList<OCFile>();
|
||||
for (OCShare share : shares) {
|
||||
// Get the path
|
||||
String path = share.getPath();
|
||||
if (share.isDirectory()) {
|
||||
path = path + FileUtils.PATH_SEPARATOR;
|
||||
}
|
||||
|
||||
for (OCShare share : shares) {
|
||||
// Get the path
|
||||
String path = share.getPath();
|
||||
if (share.isDirectory()) {
|
||||
path = path + FileUtils.PATH_SEPARATOR;
|
||||
}
|
||||
|
||||
// Update OCFile with data from share: ShareByLink ¿and publicLink?
|
||||
OCFile file = getStorageManager().getFileByPath(path);
|
||||
if (file != null) {
|
||||
if (share.getShareType().equals(ShareType.PUBLIC_LINK)) {
|
||||
file.setShareByLink(true);
|
||||
sharedFiles.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sharedFiles.size() > 0) {
|
||||
getStorageManager().updateSharedFiles(sharedFiles);
|
||||
}
|
||||
// Update OCFile with data from share: ShareByLink ¿and publicLink?
|
||||
OCFile file = getStorageManager().getFileByPath(path);
|
||||
if (file != null) {
|
||||
if (share.getShareType().equals(ShareType.PUBLIC_LINK)) {
|
||||
file.setShareByLink(true);
|
||||
sharedFiles.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getStorageManager().updateSharedFiles(sharedFiles);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue