|
@@ -51,6 +51,7 @@ import com.owncloud.android.datamodel.UploadsStorageManager;
|
|
|
import com.owncloud.android.datamodel.UploadsStorageManager.UploadStatus;
|
|
|
import com.owncloud.android.db.OCUpload;
|
|
|
import com.owncloud.android.db.PreferenceReader;
|
|
|
+import com.owncloud.android.db.UploadResult;
|
|
|
import com.owncloud.android.lib.common.OwnCloudAccount;
|
|
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
|
|
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
|
@@ -257,6 +258,17 @@ public class FileUploader extends Service
|
|
|
context.startService(i);
|
|
|
}
|
|
|
|
|
|
+ public static void retryUploadsForAccount(Account account, Context context) {
|
|
|
+ UploadsStorageManager uploadsStorageManager = new UploadsStorageManager(context.getContentResolver());
|
|
|
+ OCUpload[] failedUploads = uploadsStorageManager.getFailedUploads();
|
|
|
+ for ( OCUpload upload: failedUploads){
|
|
|
+ if (upload.getAccountName().equals(account.name) &&
|
|
|
+ upload.getLastResult() == UploadResult.CREDENTIAL_ERROR ) {
|
|
|
+ retry(context, account, upload);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Call to upload several new files
|
|
|
*/
|
|
@@ -1128,6 +1140,7 @@ public class FileUploader extends Service
|
|
|
AuthenticatorActivity.EXTRA_ACTION,
|
|
|
AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN
|
|
|
);
|
|
|
+
|
|
|
updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
|
|
updateAccountCredentials.addFlags(Intent.FLAG_FROM_BACKGROUND);
|
|
@@ -1171,7 +1184,7 @@ public class FileUploader extends Service
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
- if (!uploadResult.isSuccess()) {
|
|
|
+ if (!uploadResult.isSuccess() && !needsToUpdateCredentials ) {
|
|
|
//in case of failure, do not show details file view (because there is no file!)
|
|
|
Intent showUploadListIntent = new Intent(this, UploadListActivity.class);
|
|
|
showUploadListIntent.putExtra(FileActivity.EXTRA_FILE, upload.getFile());
|
|
@@ -1266,5 +1279,4 @@ public class FileUploader extends Service
|
|
|
// retry(context, null);
|
|
|
// }
|
|
|
|
|
|
-
|
|
|
}
|