mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
When retrying failing uploads, delay connectivity check until last possible moment
This avoids network calls if the uploads can't be done for other reason (such as missing files) Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
parent
a62373efb4
commit
c8aa577589
2 changed files with 5 additions and 4 deletions
|
@ -675,7 +675,7 @@ public class FileUploader extends Service
|
|||
/**
|
||||
* Convert current account to user. This is a temporary workaround until
|
||||
* service is migrated to new user model.
|
||||
*
|
||||
*
|
||||
* @return Optional {@link User}
|
||||
*/
|
||||
private Optional<User> getCurrentUser() {
|
||||
|
@ -1075,7 +1075,7 @@ public class FileUploader extends Service
|
|||
}
|
||||
|
||||
final Connectivity connectivity = connectivityService.getConnectivity();
|
||||
final boolean gotNetwork = connectivity.isConnected() && !connectivityService.isInternetWalled();
|
||||
final boolean gotNetwork = connectivity.isConnected();
|
||||
final boolean gotWifi = connectivity.isWifi();
|
||||
final BatteryStatus batteryStatus = powerManagementService.getBattery();
|
||||
final boolean charging = batteryStatus.isCharging() || batteryStatus.isFull();
|
||||
|
@ -1094,7 +1094,8 @@ public class FileUploader extends Service
|
|||
failedUpload.setLastResult(UploadResult.FILE_NOT_FOUND);
|
||||
uploadsStorageManager.updateUpload(failedUpload);
|
||||
}
|
||||
} else if (!isPowerSaving && gotNetwork && canUploadBeRetried(failedUpload, gotWifi, charging)) {
|
||||
} else if (!isPowerSaving && gotNetwork &&
|
||||
canUploadBeRetried(failedUpload, gotWifi, charging) && !connectivityService.isInternetWalled()) {
|
||||
// 2B. for existing local files, try restarting it if possible
|
||||
retryUpload(context, uploadUser.get(), failedUpload);
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ public final class FilesSyncHelper {
|
|||
}
|
||||
|
||||
new Thread(() -> {
|
||||
if (connectivityService.getConnectivity().isConnected() && !connectivityService.isInternetWalled()) {
|
||||
if (connectivityService.getConnectivity().isConnected()) {
|
||||
FileUploader.retryFailedUploads(
|
||||
context,
|
||||
uploadsStorageManager,
|
||||
|
|
Loading…
Reference in a new issue