Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Preserve resumable asset state

laurenspriem4a2ae201bf45
diff --git a/mobile/apps/photos/lib/services/remote_assets_service.dart b/mobile/apps/photos/lib/services/remote_assets_service.dart
index f1d30b9f55..193539c0e4 100644
--- a/mobile/apps/photos/lib/services/remote_assets_service.dart
+++ b/mobile/apps/photos/lib/services/remote_assets_service.dart
@@ -110,15 +110,13 @@ class RemoteAssetsService {
Future<void> _downloadFile(String url, String savePath) async {
_logger.info("Downloading " + url);
final probe = await _probeRemoteAsset(url);
- final preservePartialDownload =
- probe == null && await _hasResumableDownloadState(savePath);
if (_shouldUseResumableDownload(probe)) {
await _downloadFileResumable(url, savePath, probe!);
} else {
await _downloadFileSingleShot(
url,
savePath,
- preservePartialDownload: preservePartialDownload,
+ preservePartialDownload: await _hasResumableDownloadState(savePath),
);
}
@@ -614,6 +612,8 @@ class _ResumeMetadata {
final String? etag;
final String? lastModified;
+ String? get ifRangeValidator => _strongETag ?? lastModified;
+
Map<String, dynamic> toJson() {
return {
"url": url,
@@ -626,7 +626,17 @@ class _ResumeMetadata {
bool matches(_ResumeMetadata other) {
return url == other.url &&
totalBytes == other.totalBytes &&
- etag == other.etag &&
- lastModified == other.lastModified;
+ ifRangeValidator == other.ifRangeValidator;
+ }
+
+ String? get _strongETag {
+ if (etag == null) {
+ return null;
+ }
+ return _isWeakETag(etag!) ? null : etag;
+ }
+
+ static bool _isWeakETag(String value) {
+ return value.startsWith("W/") || value.startsWith("w/");
}
}