mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
Try to workaround disappeared files bug
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
5087ff4537
commit
8cabe1f3d9
1 changed files with 27 additions and 24 deletions
|
@ -42,6 +42,7 @@ import com.owncloud.android.datamodel.SyncedFolder;
|
||||||
import com.owncloud.android.datamodel.SyncedFolderProvider;
|
import com.owncloud.android.datamodel.SyncedFolderProvider;
|
||||||
import com.owncloud.android.datamodel.UploadsStorageManager;
|
import com.owncloud.android.datamodel.UploadsStorageManager;
|
||||||
import com.owncloud.android.db.OCUpload;
|
import com.owncloud.android.db.OCUpload;
|
||||||
|
import com.owncloud.android.db.UploadResult;
|
||||||
import com.owncloud.android.jobs.AutoUploadJob;
|
import com.owncloud.android.jobs.AutoUploadJob;
|
||||||
|
|
||||||
import org.lukhnos.nnio.file.FileVisitResult;
|
import org.lukhnos.nnio.file.FileVisitResult;
|
||||||
|
@ -219,36 +220,38 @@ public class FilesSyncHelper {
|
||||||
UploadsStorageManager uploadsStorageManager = new UploadsStorageManager(context.getContentResolver(), context);
|
UploadsStorageManager uploadsStorageManager = new UploadsStorageManager(context.getContentResolver(), context);
|
||||||
OCUpload[] failedUploads = uploadsStorageManager.getFailedUploads();
|
OCUpload[] failedUploads = uploadsStorageManager.getFailedUploads();
|
||||||
|
|
||||||
boolean accountExists = false;
|
boolean accountExists;
|
||||||
for (OCUpload failedUpload: failedUploads) {
|
for (OCUpload failedUpload: failedUploads) {
|
||||||
accountExists = false;
|
accountExists = false;
|
||||||
uploadsStorageManager.removeUpload(failedUpload);
|
if (!failedUpload.getLastResult().equals(UploadResult.UPLOADED)) {
|
||||||
|
uploadsStorageManager.removeUpload(failedUpload);
|
||||||
|
|
||||||
// check if accounts still exists
|
// check if accounts still exists
|
||||||
for (Account account : AccountUtils.getAccounts(context)) {
|
for (Account account : AccountUtils.getAccounts(context)) {
|
||||||
if (account.name.equals(failedUpload.getAccountName())) {
|
if (account.name.equals(failedUpload.getAccountName())) {
|
||||||
accountExists = true;
|
accountExists = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (accountExists) {
|
if (accountExists) {
|
||||||
PersistableBundleCompat bundle = new PersistableBundleCompat();
|
PersistableBundleCompat bundle = new PersistableBundleCompat();
|
||||||
bundle.putString(AutoUploadJob.LOCAL_PATH, failedUpload.getLocalPath());
|
bundle.putString(AutoUploadJob.LOCAL_PATH, failedUpload.getLocalPath());
|
||||||
bundle.putString(AutoUploadJob.REMOTE_PATH, failedUpload.getRemotePath());
|
bundle.putString(AutoUploadJob.REMOTE_PATH, failedUpload.getRemotePath());
|
||||||
bundle.putString(AutoUploadJob.ACCOUNT, failedUpload.getAccountName());
|
bundle.putString(AutoUploadJob.ACCOUNT, failedUpload.getAccountName());
|
||||||
bundle.putInt(AutoUploadJob.UPLOAD_BEHAVIOUR, failedUpload.getLocalAction());
|
bundle.putInt(AutoUploadJob.UPLOAD_BEHAVIOUR, failedUpload.getLocalAction());
|
||||||
|
|
||||||
new JobRequest.Builder(AutoUploadJob.TAG)
|
new JobRequest.Builder(AutoUploadJob.TAG)
|
||||||
.setExecutionWindow(30_000L, 80_000L)
|
.setExecutionWindow(30_000L, 80_000L)
|
||||||
.setRequiresCharging(failedUpload.isWhileChargingOnly())
|
.setRequiresCharging(failedUpload.isWhileChargingOnly())
|
||||||
.setRequiredNetworkType(failedUpload.isUseWifiOnly() ? JobRequest.NetworkType.UNMETERED :
|
.setRequiredNetworkType(failedUpload.isUseWifiOnly() ? JobRequest.NetworkType.UNMETERED :
|
||||||
JobRequest.NetworkType.CONNECTED)
|
JobRequest.NetworkType.CONNECTED)
|
||||||
.setExtras(bundle)
|
.setExtras(bundle)
|
||||||
.setRequirementsEnforced(true)
|
.setRequirementsEnforced(true)
|
||||||
.setUpdateCurrent(false)
|
.setUpdateCurrent(false)
|
||||||
.build()
|
.build()
|
||||||
.schedule();
|
.schedule();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue