@hot-updater/react-native 1.0.1 → 1.0.3
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 +4 -4
- package/src/sdkVersion.ts +1 -1
|
@@ -55,6 +55,32 @@ enum DownloadError: Error, Equatable {
|
|
|
55
55
|
return .httpStatus(httpResponse.statusCode, originCode: originCode)
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/// The size of the file a successful response leaves, or nil when the
|
|
59
|
+
/// response does not tell. A 206 answers a range: when the system resumes
|
|
60
|
+
/// an interrupted background download, `expectedContentLength` counts
|
|
61
|
+
/// only the resumed range while the file holds every byte, so the size is
|
|
62
|
+
/// the total in `Content-Range: bytes <first>-<last>/<total>`.
|
|
63
|
+
static func expectedFileSize(for response: URLResponse?) -> Int64? {
|
|
64
|
+
if let httpResponse = response as? HTTPURLResponse,
|
|
65
|
+
httpResponse.statusCode == 206 {
|
|
66
|
+
guard let contentRange = httpResponse.value(forHTTPHeaderField: "Content-Range"),
|
|
67
|
+
let separator = contentRange.lastIndex(of: "/"),
|
|
68
|
+
let total = Int64(
|
|
69
|
+
contentRange[contentRange.index(after: separator)...]
|
|
70
|
+
.trimmingCharacters(in: .whitespaces)
|
|
71
|
+
),
|
|
72
|
+
total > 0 else {
|
|
73
|
+
return nil
|
|
74
|
+
}
|
|
75
|
+
return total
|
|
76
|
+
}
|
|
77
|
+
guard let expectedContentLength = response?.expectedContentLength,
|
|
78
|
+
expectedContentLength > 0 else {
|
|
79
|
+
return nil
|
|
80
|
+
}
|
|
81
|
+
return expectedContentLength
|
|
82
|
+
}
|
|
83
|
+
|
|
58
84
|
/// The `<Code>` of an S3, R2, or GCS style `<Error>` document in the
|
|
59
85
|
/// first 4 KB of `body`, such as "AccessDenied". Nothing else from the
|
|
60
86
|
/// body is kept, and a code must be 1-64 characters of [A-Za-z0-9._-].
|
|
@@ -215,7 +241,7 @@ extension URLSessionDownloadService: URLSessionDownloadDelegate {
|
|
|
215
241
|
}
|
|
216
242
|
|
|
217
243
|
// Verify file size
|
|
218
|
-
let expectedSize = downloadTask.response
|
|
244
|
+
let expectedSize = DownloadError.expectedFileSize(for: downloadTask.response)
|
|
219
245
|
let actualSize: Int64?
|
|
220
246
|
do {
|
|
221
247
|
let attributes = try FileManager.default.attributesOfItem(atPath: location.path)
|
|
@@ -225,7 +251,7 @@ extension URLSessionDownloadService: URLSessionDownloadDelegate {
|
|
|
225
251
|
actualSize = nil
|
|
226
252
|
}
|
|
227
253
|
|
|
228
|
-
if expectedSize
|
|
254
|
+
if let expectedSize, let actualSize, actualSize != expectedSize {
|
|
229
255
|
NSLog("[DownloadService] Download incomplete: \(actualSize) / \(expectedSize) bytes")
|
|
230
256
|
// Delete incomplete file
|
|
231
257
|
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 = "1.0.
|
|
7
|
+
const HOT_UPDATER_SDK_VERSION = exports.HOT_UPDATER_SDK_VERSION = "1.0.3";
|
|
8
8
|
//# sourceMappingURL=sdkVersion.js.map
|
package/lib/module/sdkVersion.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const HOT_UPDATER_SDK_VERSION = "1.0.
|
|
1
|
+
export declare const HOT_UPDATER_SDK_VERSION = "1.0.3";
|
|
2
2
|
//# sourceMappingURL=sdkVersion.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const HOT_UPDATER_SDK_VERSION = "1.0.
|
|
1
|
+
export declare const HOT_UPDATER_SDK_VERSION = "1.0.3";
|
|
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": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "React Native OTA solution for self-hosted",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
@@ -123,9 +123,9 @@
|
|
|
123
123
|
},
|
|
124
124
|
"dependencies": {
|
|
125
125
|
"use-sync-external-store": "1.5.0",
|
|
126
|
-
"@hot-updater/protocol": "1.0.
|
|
127
|
-
"@hot-updater/plugin-
|
|
128
|
-
"@hot-updater/plugin-
|
|
126
|
+
"@hot-updater/protocol": "1.0.3",
|
|
127
|
+
"@hot-updater/plugin-insights": "1.0.3",
|
|
128
|
+
"@hot-updater/plugin-remote-config": "1.0.3"
|
|
129
129
|
},
|
|
130
130
|
"scripts": {
|
|
131
131
|
"build": "node ./scripts/sync-sdk-version.mjs run -- bob build",
|
package/src/sdkVersion.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const HOT_UPDATER_SDK_VERSION = "1.0.
|
|
1
|
+
export const HOT_UPDATER_SDK_VERSION = "1.0.3";
|