@capgo/capacitor-updater 8.52.1 → 8.53.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +198 -66
- package/android/build.gradle +2 -1
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +414 -150
- package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +693 -217
- package/android/src/main/java/ee/forgr/capacitor_updater/CryptoCipher.java +2 -1
- package/android/src/main/java/ee/forgr/capacitor_updater/DelayUpdateUtils.java +226 -105
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +30 -10
- package/android/src/main/java/ee/forgr/capacitor_updater/HeadlessUpdateWorker.java +324 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/InternalUtils.java +34 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/NativeUpdatePrompt.java +303 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/ShakeMenu.java +4 -4
- package/android/src/main/java/ee/forgr/capacitor_updater/Version.java +1 -1
- package/dist/docs.json +378 -27
- package/dist/esm/definitions.d.ts +206 -7
- package/dist/esm/definitions.js.map +1 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapacitorUpdaterPlugin/AES.swift +104 -52
- package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +360 -104
- package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +166 -10
- package/ios/Sources/CapacitorUpdaterPlugin/CryptoCipher.swift +2 -1
- package/ios/Sources/CapacitorUpdaterPlugin/DelayUpdateUtils.swift +202 -90
- package/ios/Sources/CapacitorUpdaterPlugin/NativeUpdatePrompt.swift +183 -0
- package/ios/Sources/CapacitorUpdaterPlugin/ShakeMenu.swift +5 -2
- package/package.json +7 -3
|
@@ -150,11 +150,12 @@ public class CryptoCipher {
|
|
|
150
150
|
}
|
|
151
151
|
return;
|
|
152
152
|
}
|
|
153
|
+
// The bundle is encrypted from here on: an unusable key must fail, never leave it encrypted.
|
|
153
154
|
if (!publicKey.startsWith("-----BEGIN RSA PUBLIC KEY-----")) {
|
|
154
155
|
if (logger != null) {
|
|
155
156
|
logger.error("The public key is not a valid RSA Public key");
|
|
156
157
|
}
|
|
157
|
-
|
|
158
|
+
throw new IOException("AES file decryption failed: the public key is not a valid RSA public key");
|
|
158
159
|
}
|
|
159
160
|
|
|
160
161
|
try {
|
|
@@ -16,6 +16,9 @@ public class DelayUpdateUtils {
|
|
|
16
16
|
private final Logger logger;
|
|
17
17
|
|
|
18
18
|
public static final String DELAY_CONDITION_PREFERENCES = "DELAY_CONDITION_PREFERENCES_CAPGO";
|
|
19
|
+
public static final String DELAY_CONDITION_MODE_PREFERENCES = "DELAY_CONDITION_MODE_PREFERENCES_CAPGO";
|
|
20
|
+
public static final String DELAY_CONDITION_MODE_AND = "and";
|
|
21
|
+
public static final String DELAY_CONDITION_MODE_OR = "or";
|
|
19
22
|
public static final String BACKGROUND_TIMESTAMP_KEY = "BACKGROUND_TIMESTAMP_KEY_CAPGO";
|
|
20
23
|
|
|
21
24
|
private final SharedPreferences prefs;
|
|
@@ -38,128 +41,242 @@ public class DelayUpdateUtils {
|
|
|
38
41
|
public void checkCancelDelay(CancelDelaySource source) {
|
|
39
42
|
String delayUpdatePreferences = prefs.getString(DELAY_CONDITION_PREFERENCES, "[]");
|
|
40
43
|
ArrayList<DelayCondition> delayConditionList = parseDelayConditions(delayUpdatePreferences);
|
|
44
|
+
if (delayConditionList.isEmpty()) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
final boolean useOrMode = isOrConditionMode();
|
|
41
49
|
ArrayList<DelayCondition> delayConditionListToKeep = new ArrayList<>(delayConditionList.size());
|
|
42
50
|
int index = 0;
|
|
51
|
+
boolean anyConditionMet = false;
|
|
43
52
|
|
|
44
53
|
for (DelayCondition condition : delayConditionList) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"Background condition (value: " +
|
|
59
|
-
value +
|
|
60
|
-
") had an invalid value at index " +
|
|
61
|
-
index +
|
|
62
|
-
". We will likely remove it."
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (delta > longValue) {
|
|
67
|
-
logger.info(
|
|
68
|
-
"Background condition (value: " +
|
|
69
|
-
value +
|
|
70
|
-
") deleted at index " +
|
|
71
|
-
index +
|
|
72
|
-
". Delta: " +
|
|
73
|
-
delta +
|
|
74
|
-
", longValue: " +
|
|
75
|
-
longValue
|
|
76
|
-
);
|
|
77
|
-
} else {
|
|
78
|
-
delayConditionListToKeep.add(condition);
|
|
79
|
-
logger.info(
|
|
80
|
-
"Background delay (value: " +
|
|
81
|
-
value +
|
|
82
|
-
") condition kept at index " +
|
|
83
|
-
index +
|
|
84
|
-
" (source: " +
|
|
85
|
-
source.toString() +
|
|
86
|
-
")"
|
|
87
|
-
);
|
|
88
|
-
}
|
|
54
|
+
ConditionCheckResult result = evaluateCondition(condition, source, index);
|
|
55
|
+
if (result.met) {
|
|
56
|
+
anyConditionMet = true;
|
|
57
|
+
if (!useOrMode) {
|
|
58
|
+
logger.info(result.logMessage);
|
|
59
|
+
}
|
|
60
|
+
} else if (!useOrMode) {
|
|
61
|
+
if (result.keep) {
|
|
62
|
+
delayConditionListToKeep.add(condition);
|
|
63
|
+
}
|
|
64
|
+
if (result.logMessage != null) {
|
|
65
|
+
if (result.error) {
|
|
66
|
+
logger.error(result.logMessage);
|
|
89
67
|
} else {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
68
|
+
logger.info(result.logMessage);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
} else if (result.keep) {
|
|
72
|
+
delayConditionListToKeep.add(condition);
|
|
73
|
+
}
|
|
74
|
+
index++;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (useOrMode) {
|
|
78
|
+
if (anyConditionMet || delayConditionListToKeep.isEmpty()) {
|
|
79
|
+
logger.info("Delay condition met in OR mode (source: " + source + "), canceling delay");
|
|
80
|
+
this.cancelDelay("checkCancelDelay");
|
|
81
|
+
} else if (delayConditionListToKeep.size() != delayConditionList.size()) {
|
|
82
|
+
this.setMultiDelay(convertDelayConditionsToJson(delayConditionListToKeep));
|
|
83
|
+
}
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (delayConditionListToKeep.isEmpty()) {
|
|
88
|
+
this.cancelDelay("checkCancelDelay");
|
|
89
|
+
} else {
|
|
90
|
+
this.setMultiDelay(convertDelayConditionsToJson(delayConditionListToKeep));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private static final class ConditionCheckResult {
|
|
95
|
+
|
|
96
|
+
final boolean met;
|
|
97
|
+
final boolean keep;
|
|
98
|
+
final boolean error;
|
|
99
|
+
final String logMessage;
|
|
100
|
+
|
|
101
|
+
ConditionCheckResult(boolean met, boolean keep, boolean error, String logMessage) {
|
|
102
|
+
this.met = met;
|
|
103
|
+
this.keep = keep;
|
|
104
|
+
this.error = error;
|
|
105
|
+
this.logMessage = logMessage;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private ConditionCheckResult evaluateCondition(DelayCondition condition, CancelDelaySource source, int index) {
|
|
110
|
+
DelayUntilNext kind = condition.getKind();
|
|
111
|
+
String value = condition.getValue();
|
|
112
|
+
switch (kind) {
|
|
113
|
+
case background:
|
|
114
|
+
if (source == CancelDelaySource.FOREGROUND) {
|
|
115
|
+
long backgroundedAt = getBackgroundTimestamp();
|
|
116
|
+
long now = System.currentTimeMillis();
|
|
117
|
+
long delta = Math.max(0, now - backgroundedAt);
|
|
118
|
+
long longValue = 0L;
|
|
119
|
+
try {
|
|
120
|
+
longValue = Long.parseLong(value);
|
|
121
|
+
} catch (NumberFormatException e) {
|
|
122
|
+
return new ConditionCheckResult(
|
|
123
|
+
false,
|
|
124
|
+
false,
|
|
125
|
+
true,
|
|
126
|
+
"Background condition (value: " +
|
|
93
127
|
value +
|
|
94
|
-
")
|
|
128
|
+
") had an invalid value at index " +
|
|
95
129
|
index +
|
|
96
|
-
"
|
|
97
|
-
source.toString() +
|
|
98
|
-
")"
|
|
130
|
+
". We will likely remove it."
|
|
99
131
|
);
|
|
100
132
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
133
|
+
|
|
134
|
+
if (delta > longValue) {
|
|
135
|
+
return new ConditionCheckResult(
|
|
136
|
+
true,
|
|
137
|
+
false,
|
|
138
|
+
false,
|
|
139
|
+
"Background condition (value: " +
|
|
140
|
+
value +
|
|
141
|
+
") deleted at index " +
|
|
142
|
+
index +
|
|
143
|
+
". Delta: " +
|
|
144
|
+
delta +
|
|
145
|
+
", longValue: " +
|
|
146
|
+
longValue
|
|
109
147
|
);
|
|
110
148
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
149
|
+
return new ConditionCheckResult(
|
|
150
|
+
false,
|
|
151
|
+
true,
|
|
152
|
+
false,
|
|
153
|
+
"Background delay (value: " + value + ") condition kept at index " + index + " (source: " + source + ")"
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
return new ConditionCheckResult(
|
|
157
|
+
false,
|
|
158
|
+
true,
|
|
159
|
+
false,
|
|
160
|
+
"Background delay (value: " + value + ") condition kept at index " + index + " (source: " + source + ")"
|
|
161
|
+
);
|
|
162
|
+
case kill:
|
|
163
|
+
if (source == CancelDelaySource.KILLED) {
|
|
164
|
+
return new ConditionCheckResult(
|
|
165
|
+
true,
|
|
166
|
+
false,
|
|
167
|
+
false,
|
|
168
|
+
"Kill delay (value: " + value + ") condition removed at index " + index + " after app kill"
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
return new ConditionCheckResult(
|
|
172
|
+
false,
|
|
173
|
+
true,
|
|
174
|
+
false,
|
|
175
|
+
"Kill delay (value: " + value + ") condition kept at index " + index + " (source: " + source + ")"
|
|
176
|
+
);
|
|
177
|
+
case date:
|
|
178
|
+
if (!"".equals(value)) {
|
|
179
|
+
Date date = parseDateCondition(value);
|
|
180
|
+
if (date != null) {
|
|
181
|
+
if (new Date().compareTo(date) > 0) {
|
|
182
|
+
return new ConditionCheckResult(
|
|
183
|
+
true,
|
|
184
|
+
false,
|
|
185
|
+
false,
|
|
186
|
+
"Date delay (value: " + value + ") condition removed due to expired date at index " + index
|
|
187
|
+
);
|
|
124
188
|
}
|
|
125
|
-
|
|
126
|
-
|
|
189
|
+
return new ConditionCheckResult(
|
|
190
|
+
false,
|
|
191
|
+
true,
|
|
192
|
+
false,
|
|
193
|
+
"Date delay (value: " + value + ") condition kept at index " + index
|
|
194
|
+
);
|
|
127
195
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
196
|
+
return new ConditionCheckResult(
|
|
197
|
+
false,
|
|
198
|
+
false,
|
|
199
|
+
true,
|
|
200
|
+
"Date delay (value: " + value + ") condition removed due to parsing issue at index " + index
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
return new ConditionCheckResult(
|
|
204
|
+
false,
|
|
205
|
+
false,
|
|
206
|
+
false,
|
|
207
|
+
"Date delay (value: " + value + ") condition removed due to empty value at index " + index
|
|
208
|
+
);
|
|
209
|
+
case nativeVersion:
|
|
210
|
+
if (!"".equals(value)) {
|
|
211
|
+
try {
|
|
212
|
+
final Version versionLimit = new Version(value);
|
|
213
|
+
if (this.currentVersionNative.isAtLeast(versionLimit)) {
|
|
214
|
+
return new ConditionCheckResult(
|
|
215
|
+
true,
|
|
216
|
+
false,
|
|
217
|
+
false,
|
|
218
|
+
"Native version delay (value: " + value + ") condition removed due to above limit at index " + index
|
|
149
219
|
);
|
|
150
220
|
}
|
|
151
|
-
|
|
152
|
-
|
|
221
|
+
return new ConditionCheckResult(
|
|
222
|
+
false,
|
|
223
|
+
true,
|
|
224
|
+
false,
|
|
225
|
+
"Native version delay (value: " + value + ") condition kept at index " + index
|
|
226
|
+
);
|
|
227
|
+
} catch (final Exception e) {
|
|
228
|
+
return new ConditionCheckResult(
|
|
229
|
+
false,
|
|
230
|
+
false,
|
|
231
|
+
true,
|
|
232
|
+
"Native version delay (value: " +
|
|
233
|
+
value +
|
|
234
|
+
") condition removed due to parsing issue at index " +
|
|
235
|
+
index +
|
|
236
|
+
" " +
|
|
237
|
+
e.getMessage()
|
|
238
|
+
);
|
|
153
239
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
240
|
+
}
|
|
241
|
+
return new ConditionCheckResult(
|
|
242
|
+
false,
|
|
243
|
+
false,
|
|
244
|
+
false,
|
|
245
|
+
"Native version delay (value: " + value + ") condition removed due to empty value at index " + index
|
|
246
|
+
);
|
|
247
|
+
default:
|
|
248
|
+
return new ConditionCheckResult(false, false, true, "Unknown delay condition kind at index " + index);
|
|
157
249
|
}
|
|
250
|
+
}
|
|
158
251
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
252
|
+
public boolean isOrConditionMode() {
|
|
253
|
+
return DELAY_CONDITION_MODE_OR.equals(getConditionMode());
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
public String getConditionMode() {
|
|
257
|
+
String mode = prefs.getString(DELAY_CONDITION_MODE_PREFERENCES, DELAY_CONDITION_MODE_AND);
|
|
258
|
+
if (DELAY_CONDITION_MODE_OR.equals(mode)) {
|
|
259
|
+
return DELAY_CONDITION_MODE_OR;
|
|
260
|
+
}
|
|
261
|
+
return DELAY_CONDITION_MODE_AND;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
public Boolean setConditionMode(String conditionMode) {
|
|
265
|
+
try {
|
|
266
|
+
String normalized = DELAY_CONDITION_MODE_OR.equals(conditionMode) ? DELAY_CONDITION_MODE_OR : DELAY_CONDITION_MODE_AND;
|
|
267
|
+
if (!DELAY_CONDITION_MODE_AND.equals(conditionMode) && !DELAY_CONDITION_MODE_OR.equals(conditionMode)) {
|
|
268
|
+
logger.warn("Unknown delay condition mode '" + conditionMode + "', defaulting to '" + DELAY_CONDITION_MODE_AND + "'");
|
|
269
|
+
}
|
|
270
|
+
this.editor.putString(DELAY_CONDITION_MODE_PREFERENCES, normalized);
|
|
271
|
+
if (!this.editor.commit()) {
|
|
272
|
+
logger.error("Failed to save delay condition mode: commit returned false");
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
logger.info("Delay condition mode saved: " + normalized);
|
|
276
|
+
return true;
|
|
277
|
+
} catch (final Exception e) {
|
|
278
|
+
logger.error("Failed to save delay condition mode: " + e.getMessage());
|
|
279
|
+
return false;
|
|
163
280
|
}
|
|
164
281
|
}
|
|
165
282
|
|
|
@@ -254,7 +371,10 @@ public class DelayUpdateUtils {
|
|
|
254
371
|
public Boolean setMultiDelay(String delayConditions) {
|
|
255
372
|
try {
|
|
256
373
|
this.editor.putString(DELAY_CONDITION_PREFERENCES, delayConditions);
|
|
257
|
-
this.editor.commit()
|
|
374
|
+
if (!this.editor.commit()) {
|
|
375
|
+
logger.error("Failed to delay update: commit returned false");
|
|
376
|
+
return false;
|
|
377
|
+
}
|
|
258
378
|
logger.info("Delay update saved");
|
|
259
379
|
return true;
|
|
260
380
|
} catch (final Exception e) {
|
|
@@ -295,6 +415,7 @@ public class DelayUpdateUtils {
|
|
|
295
415
|
public boolean cancelDelay(String source) {
|
|
296
416
|
try {
|
|
297
417
|
this.editor.remove(DELAY_CONDITION_PREFERENCES);
|
|
418
|
+
this.editor.remove(DELAY_CONDITION_MODE_PREFERENCES);
|
|
298
419
|
this.editor.commit();
|
|
299
420
|
logger.info("All delays canceled from " + source);
|
|
300
421
|
return true;
|
|
@@ -277,8 +277,21 @@ public class DownloadService extends Worker {
|
|
|
277
277
|
}
|
|
278
278
|
|
|
279
279
|
private Result createFailureResult(String error) {
|
|
280
|
-
|
|
281
|
-
|
|
280
|
+
return createFailureResult(error, null, null, false);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
private Result createFailureResult(String error, String version, String dest, boolean isManifest) {
|
|
284
|
+
Data.Builder builder = new Data.Builder().putString(ERROR, error);
|
|
285
|
+
if (version != null) {
|
|
286
|
+
builder.putString(VERSION, version);
|
|
287
|
+
}
|
|
288
|
+
if (dest != null) {
|
|
289
|
+
builder.putString(FILEDEST, dest);
|
|
290
|
+
}
|
|
291
|
+
if (isManifest) {
|
|
292
|
+
builder.putBoolean(IS_MANIFEST, true);
|
|
293
|
+
}
|
|
294
|
+
return Result.failure(builder.build());
|
|
282
295
|
}
|
|
283
296
|
|
|
284
297
|
private Result createSuccessResult(String dest, String version, String sessionKey, String checksum, boolean isManifest) {
|
|
@@ -469,16 +482,16 @@ public class DownloadService extends Worker {
|
|
|
469
482
|
@NonNull
|
|
470
483
|
@Override
|
|
471
484
|
public Result doWork() {
|
|
485
|
+
final String documentsDir = getInputData().getString(DOCDIR);
|
|
486
|
+
final String dest = getInputData().getString(FILEDEST);
|
|
487
|
+
final String version = getInputData().getString(VERSION);
|
|
488
|
+
final boolean isManifest = getInputData().getBoolean(IS_MANIFEST, false);
|
|
472
489
|
try {
|
|
473
490
|
String url = getInputData().getString(URL);
|
|
474
491
|
String id = getInputData().getString(ID);
|
|
475
|
-
String documentsDir = getInputData().getString(DOCDIR);
|
|
476
|
-
String dest = getInputData().getString(FILEDEST);
|
|
477
|
-
String version = getInputData().getString(VERSION);
|
|
478
492
|
String sessionKey = getInputData().getString(SESSIONKEY);
|
|
479
493
|
String checksum = getInputData().getString(CHECKSUM);
|
|
480
494
|
String publicKey = getInputData().getString(PUBLIC_KEY);
|
|
481
|
-
boolean isManifest = getInputData().getBoolean(IS_MANIFEST, false);
|
|
482
495
|
|
|
483
496
|
logger.debug("doWork isManifest: " + isManifest);
|
|
484
497
|
|
|
@@ -488,10 +501,12 @@ public class DownloadService extends Worker {
|
|
|
488
501
|
handleManifestDownload(id, documentsDir, dest, version, sessionKey, publicKey, manifest);
|
|
489
502
|
return createSuccessResult(dest, version, sessionKey, checksum, true);
|
|
490
503
|
} else if (isStopped()) {
|
|
491
|
-
|
|
504
|
+
CapgoUpdater.deleteManifestStagingFolderAt(documentsDir != null ? new File(documentsDir) : null, dest, logger);
|
|
505
|
+
return createFailureResult("download_cancelled", version, dest, true);
|
|
492
506
|
} else {
|
|
493
507
|
logger.error("Manifest is null");
|
|
494
|
-
|
|
508
|
+
CapgoUpdater.deleteManifestStagingFolderAt(documentsDir != null ? new File(documentsDir) : null, dest, logger);
|
|
509
|
+
return createFailureResult("Manifest is null", version, dest, true);
|
|
495
510
|
}
|
|
496
511
|
} else {
|
|
497
512
|
handleSingleFileDownload(url, id, documentsDir, dest, version, sessionKey, checksum, publicKey);
|
|
@@ -503,7 +518,10 @@ public class DownloadService extends Worker {
|
|
|
503
518
|
}
|
|
504
519
|
return Result.retry();
|
|
505
520
|
} catch (Exception e) {
|
|
506
|
-
|
|
521
|
+
if (isManifest) {
|
|
522
|
+
CapgoUpdater.deleteManifestStagingFolderAt(documentsDir != null ? new File(documentsDir) : null, dest, logger);
|
|
523
|
+
}
|
|
524
|
+
return createFailureResult(e.getMessage(), version, dest, isManifest);
|
|
507
525
|
}
|
|
508
526
|
}
|
|
509
527
|
|
|
@@ -855,7 +873,9 @@ public class DownloadService extends Worker {
|
|
|
855
873
|
ZipWritePlan writePlan = planZipResumeWrite(responseCode, downloadedBytes, response.header("Content-Range"));
|
|
856
874
|
long responseBodyLength = responseBody.contentLength();
|
|
857
875
|
long contentLength = shouldAppendHttpBody(writePlan.statusCode, writePlan.writeOffset)
|
|
858
|
-
?
|
|
876
|
+
? responseBodyLength >= 0
|
|
877
|
+
? responseBodyLength + writePlan.writeOffset
|
|
878
|
+
: -1
|
|
859
879
|
: responseBodyLength;
|
|
860
880
|
|
|
861
881
|
// Check if we have enough space for the actual file
|