mirror of
https://github.com/nextcloud/android.git
synced 2024-11-29 02:38:58 +03:00
Merge pull request #6573 from nextcloud/uploadStorageTest
Remove all uploads after test for sure
This commit is contained in:
commit
eedb5008bb
2 changed files with 22 additions and 14 deletions
|
@ -183,9 +183,7 @@ public class UploadStorageManagerTest extends AbstractIT {
|
|||
}
|
||||
|
||||
private void deleteAllUploads() {
|
||||
for (Account account : getAllAccounts()) {
|
||||
uploadsStorageManager.removeAccountUploads(account);
|
||||
}
|
||||
uploadsStorageManager.removeAllUploads();
|
||||
|
||||
assertEquals(0, uploadsStorageManager.getAllStoredUploads().length);
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ import java.util.Locale;
|
|||
import java.util.Observable;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
/**
|
||||
* Database helper for storing list of files to be uploaded, including status
|
||||
|
@ -581,17 +582,17 @@ public class UploadsStorageManager extends Observable {
|
|||
ContentValues cv = new ContentValues();
|
||||
cv.put(ProviderTableMeta.UPLOADS_STATUS, UploadStatus.UPLOAD_FAILED.getValue());
|
||||
cv.put(
|
||||
ProviderTableMeta.UPLOADS_LAST_RESULT,
|
||||
fail != null ? fail.getValue() : UploadResult.UNKNOWN.getValue()
|
||||
);
|
||||
ProviderTableMeta.UPLOADS_LAST_RESULT,
|
||||
fail != null ? fail.getValue() : UploadResult.UNKNOWN.getValue()
|
||||
);
|
||||
cv.put(ProviderTableMeta.UPLOADS_UPLOAD_END_TIMESTAMP, Calendar.getInstance().getTimeInMillis());
|
||||
|
||||
int result = getDB().update(
|
||||
ProviderTableMeta.CONTENT_URI_UPLOADS,
|
||||
cv,
|
||||
ProviderTableMeta.UPLOADS_STATUS + "=?",
|
||||
new String[]{String.valueOf(UploadStatus.UPLOAD_IN_PROGRESS.getValue())}
|
||||
);
|
||||
ProviderTableMeta.CONTENT_URI_UPLOADS,
|
||||
cv,
|
||||
ProviderTableMeta.UPLOADS_STATUS + "=?",
|
||||
new String[]{String.valueOf(UploadStatus.UPLOAD_IN_PROGRESS.getValue())}
|
||||
);
|
||||
|
||||
if (result == 0) {
|
||||
Log_OC.v(TAG, "No upload was killed");
|
||||
|
@ -603,12 +604,21 @@ public class UploadsStorageManager extends Observable {
|
|||
return result;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public int removeAllUploads() {
|
||||
Log_OC.v(TAG, "Delete all uploads!");
|
||||
return getDB().delete(
|
||||
ProviderTableMeta.CONTENT_URI_UPLOADS,
|
||||
"",
|
||||
new String[]{});
|
||||
}
|
||||
|
||||
public int removeAccountUploads(Account account) {
|
||||
Log_OC.v(TAG, "Delete all uploads for account " + account.name);
|
||||
return getDB().delete(
|
||||
ProviderTableMeta.CONTENT_URI_UPLOADS,
|
||||
ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "=?",
|
||||
new String[]{account.name});
|
||||
ProviderTableMeta.CONTENT_URI_UPLOADS,
|
||||
ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "=?",
|
||||
new String[]{account.name});
|
||||
}
|
||||
|
||||
public enum UploadStatus {
|
||||
|
|
Loading…
Reference in a new issue