@hot-updater/react-native 0.36.18 → 0.36.19
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/ios/HotUpdater/Internal/URLSessionDownloadService.swift +28 -2
- package/lib/commonjs/sdkVersion.js +1 -1
- package/lib/module/sdkVersion.js +1 -1
- package/lib/typescript/commonjs/sdkVersion.d.ts +1 -1
- package/lib/typescript/module/sdkVersion.d.ts +1 -1
- package/package.json +6 -6
- package/src/sdkVersion.ts +1 -1
|
@@ -26,6 +26,32 @@ protocol DownloadService {
|
|
|
26
26
|
enum DownloadError: Error {
|
|
27
27
|
case incompleteDownload(expected: Int64, actual: Int64)
|
|
28
28
|
case invalidContentLength
|
|
29
|
+
|
|
30
|
+
/// The size of the file a successful response leaves, or nil when the
|
|
31
|
+
/// response does not tell. A 206 answers a range: when the system resumes
|
|
32
|
+
/// an interrupted background download, `expectedContentLength` counts
|
|
33
|
+
/// only the resumed range while the file holds every byte, so the size is
|
|
34
|
+
/// the total in `Content-Range: bytes <first>-<last>/<total>`.
|
|
35
|
+
static func expectedFileSize(for response: URLResponse?) -> Int64? {
|
|
36
|
+
if let httpResponse = response as? HTTPURLResponse,
|
|
37
|
+
httpResponse.statusCode == 206 {
|
|
38
|
+
guard let contentRange = httpResponse.value(forHTTPHeaderField: "Content-Range"),
|
|
39
|
+
let separator = contentRange.lastIndex(of: "/"),
|
|
40
|
+
let total = Int64(
|
|
41
|
+
contentRange[contentRange.index(after: separator)...]
|
|
42
|
+
.trimmingCharacters(in: .whitespaces)
|
|
43
|
+
),
|
|
44
|
+
total > 0 else {
|
|
45
|
+
return nil
|
|
46
|
+
}
|
|
47
|
+
return total
|
|
48
|
+
}
|
|
49
|
+
guard let expectedContentLength = response?.expectedContentLength,
|
|
50
|
+
expectedContentLength > 0 else {
|
|
51
|
+
return nil
|
|
52
|
+
}
|
|
53
|
+
return expectedContentLength
|
|
54
|
+
}
|
|
29
55
|
}
|
|
30
56
|
|
|
31
57
|
// Task state for persistence and recovery
|
|
@@ -161,7 +187,7 @@ extension URLSessionDownloadService: URLSessionDownloadDelegate {
|
|
|
161
187
|
}
|
|
162
188
|
|
|
163
189
|
// Verify file size
|
|
164
|
-
let expectedSize = downloadTask.response
|
|
190
|
+
let expectedSize = DownloadError.expectedFileSize(for: downloadTask.response)
|
|
165
191
|
let actualSize: Int64?
|
|
166
192
|
do {
|
|
167
193
|
let attributes = try FileManager.default.attributesOfItem(atPath: location.path)
|
|
@@ -171,7 +197,7 @@ extension URLSessionDownloadService: URLSessionDownloadDelegate {
|
|
|
171
197
|
actualSize = nil
|
|
172
198
|
}
|
|
173
199
|
|
|
174
|
-
if expectedSize
|
|
200
|
+
if let expectedSize, let actualSize, actualSize != expectedSize {
|
|
175
201
|
NSLog("[DownloadService] Download incomplete: \(actualSize) / \(expectedSize) bytes")
|
|
176
202
|
// Delete incomplete file
|
|
177
203
|
try? FileManager.default.removeItem(at: location)
|
|
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.HOT_UPDATER_SDK_VERSION = void 0;
|
|
7
|
-
const HOT_UPDATER_SDK_VERSION = exports.HOT_UPDATER_SDK_VERSION = "0.36.
|
|
7
|
+
const HOT_UPDATER_SDK_VERSION = exports.HOT_UPDATER_SDK_VERSION = "0.36.19";
|
|
8
8
|
//# sourceMappingURL=sdkVersion.js.map
|
package/lib/module/sdkVersion.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const HOT_UPDATER_SDK_VERSION = "0.36.
|
|
1
|
+
export declare const HOT_UPDATER_SDK_VERSION = "0.36.19";
|
|
2
2
|
//# sourceMappingURL=sdkVersion.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const HOT_UPDATER_SDK_VERSION = "0.36.
|
|
1
|
+
export declare const HOT_UPDATER_SDK_VERSION = "0.36.19";
|
|
2
2
|
//# sourceMappingURL=sdkVersion.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/react-native",
|
|
3
|
-
"version": "0.36.
|
|
3
|
+
"version": "0.36.19",
|
|
4
4
|
"description": "React Native OTA solution for self-hosted",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
@@ -131,14 +131,14 @@
|
|
|
131
131
|
"react-native-builder-bob": "0.41.0",
|
|
132
132
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
133
133
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
134
|
-
"hot-updater": "0.36.
|
|
134
|
+
"hot-updater": "0.36.19"
|
|
135
135
|
},
|
|
136
136
|
"dependencies": {
|
|
137
137
|
"use-sync-external-store": "1.5.0",
|
|
138
|
-
"@hot-updater/cli-tools": "0.36.
|
|
139
|
-
"@hot-updater/core": "0.36.
|
|
140
|
-
"@hot-updater/js": "0.36.
|
|
141
|
-
"@hot-updater/plugin-core": "0.36.
|
|
138
|
+
"@hot-updater/cli-tools": "0.36.19",
|
|
139
|
+
"@hot-updater/core": "0.36.19",
|
|
140
|
+
"@hot-updater/js": "0.36.19",
|
|
141
|
+
"@hot-updater/plugin-core": "0.36.19"
|
|
142
142
|
},
|
|
143
143
|
"scripts": {
|
|
144
144
|
"build": "node ./scripts/sync-sdk-version.mjs run -- bob build && tsc -p plugin/tsconfig.build.json",
|
package/src/sdkVersion.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const HOT_UPDATER_SDK_VERSION = "0.36.
|
|
1
|
+
export const HOT_UPDATER_SDK_VERSION = "0.36.19";
|