mirror of https://github.com/nextcloud/android
Remove uploads if user is disabled, to prevent recurring retries
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
326d229294
commit
76d579927b
|
@ -43,6 +43,7 @@ import com.owncloud.android.datamodel.FileDataStorageManager
|
|||
import com.owncloud.android.datamodel.ThumbnailsCacheManager
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager
|
||||
import com.owncloud.android.db.OCUpload
|
||||
import com.owncloud.android.db.UploadResult
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory
|
||||
import com.owncloud.android.lib.common.network.OnDatatransferProgressListener
|
||||
|
@ -50,6 +51,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
|||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.lib.resources.files.FileUtils
|
||||
import com.owncloud.android.lib.resources.users.GetUserInfoRemoteOperation
|
||||
import com.owncloud.android.operations.UploadFileOperation
|
||||
import com.owncloud.android.ui.activity.ConflictsResolveActivity
|
||||
import com.owncloud.android.ui.activity.UploadListActivity
|
||||
|
@ -104,6 +106,22 @@ class FilesUploadWorker(
|
|||
private fun handlePendingUploads(uploads: List<OCUpload>, accountName: String) {
|
||||
val user = userAccountManager.getUser(accountName)
|
||||
|
||||
if (uploads.any { it.lastResult == UploadResult.USER_DISABLED }) {
|
||||
// check if user is able to log in
|
||||
val factory = OwnCloudClientManagerFactory.getDefaultSingleton()
|
||||
val client = factory.getNextcloudClientFor(user.get().toOwnCloudAccount(), context)
|
||||
val userInfo = GetUserInfoRemoteOperation().execute(client)
|
||||
|
||||
if (!userInfo.isSuccess) {
|
||||
for (upload in uploads) {
|
||||
// user not present anymore, remove upload
|
||||
uploadsStorageManager.removeUpload(upload.uploadId)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
for (upload in uploads) {
|
||||
// create upload file operation
|
||||
if (user.isPresent) {
|
||||
|
|
|
@ -196,7 +196,6 @@ public class OCUpload implements Parcelable {
|
|||
*/
|
||||
public void setUploadStatus(UploadStatus uploadStatus) {
|
||||
this.uploadStatus = uploadStatus;
|
||||
setLastResult(UploadResult.UNKNOWN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,7 +44,8 @@ public enum UploadResult {
|
|||
OLD_ANDROID_API(18),
|
||||
SYNC_CONFLICT(19),
|
||||
CANNOT_CREATE_FILE(20),
|
||||
LOCAL_STORAGE_NOT_COPIED(21);
|
||||
LOCAL_STORAGE_NOT_COPIED(21),
|
||||
USER_DISABLED(22);
|
||||
|
||||
private final int value;
|
||||
|
||||
|
@ -104,6 +105,8 @@ public enum UploadResult {
|
|||
return CANNOT_CREATE_FILE;
|
||||
case 21:
|
||||
return LOCAL_STORAGE_NOT_COPIED;
|
||||
case 22:
|
||||
return USER_DISABLED;
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
@ -162,6 +165,8 @@ public enum UploadResult {
|
|||
return VIRUS_DETECTED;
|
||||
case CANNOT_CREATE_FILE:
|
||||
return CANNOT_CREATE_FILE;
|
||||
case USER_DISABLED:
|
||||
return USER_DISABLED;
|
||||
default:
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
|
|
@ -191,7 +191,7 @@ public class FileUploader extends Service
|
|||
public static final int LOCAL_BEHAVIOUR_FORGET = 2;
|
||||
public static final int LOCAL_BEHAVIOUR_DELETE = 3;
|
||||
|
||||
private static boolean forceNewUploadWorker = false;
|
||||
private static boolean forceNewUploadWorker = true; // if everything works, we can remove it after next release
|
||||
|
||||
private Notification mNotification;
|
||||
private Looper mServiceLooper;
|
||||
|
|
|
@ -711,6 +711,9 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|||
case LOCAL_STORAGE_NOT_COPIED:
|
||||
status = parentActivity.getString(R.string.upload_local_storage_not_copied);
|
||||
break;
|
||||
case USER_DISABLED:
|
||||
status = parentActivity.getString(R.string.user_disabled);
|
||||
break;
|
||||
default:
|
||||
status = parentActivity.getString(R.string.upload_unknown_error);
|
||||
break;
|
||||
|
|
|
@ -1107,4 +1107,5 @@
|
|||
<string name="sub_folder_rule_year">Year</string>
|
||||
<string name="sub_folder_rule_month">Year/Month</string>
|
||||
<string name="sub_folder_rule_day">Year/Month/Day</string>
|
||||
<string name="user_disabled">User disabled</string>
|
||||
</resources>
|
||||
|
|
|
@ -8,7 +8,7 @@ buildscript {
|
|||
daggerVersion = "2.47"
|
||||
markwonVersion = "4.6.2"
|
||||
prismVersion = "2.0.0"
|
||||
androidLibraryVersion = "master-SNAPSHOT"
|
||||
androidLibraryVersion = "disabled-SNAPSHOT"
|
||||
mockitoVersion = "4.11.0"
|
||||
mockitoKotlinVersion = "4.1.0"
|
||||
mockkVersion = "1.13.3"
|
||||
|
|
Loading…
Reference in New Issue