react-native-update 10.37.20 → 10.38.0-beta.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-CN.md +4 -4
- package/README.md +2 -12
- package/android/bin/.settings/org.eclipse.buildship.core.prefs +13 -0
- package/android/build.gradle +4 -0
- package/android/jni/Android.mk +14 -1
- package/android/jni/Application.mk +5 -2
- package/android/lib/arm64-v8a/librnupdate.so +0 -0
- package/android/lib/armeabi-v7a/librnupdate.so +0 -0
- package/android/lib/x86/librnupdate.so +0 -0
- package/android/lib/x86_64/librnupdate.so +0 -0
- package/android/src/main/java/cn/reactnative/modules/update/ArchivePatchPlanResult.java +6 -0
- package/android/src/main/java/cn/reactnative/modules/update/CopyGroupResult.java +6 -0
- package/android/src/main/java/cn/reactnative/modules/update/DownloadTask.java +155 -156
- package/android/src/main/java/cn/reactnative/modules/update/NativeUpdateCore.java +34 -0
- package/android/src/main/java/cn/reactnative/modules/update/StateCoreResult.java +16 -0
- package/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java +131 -48
- package/cpp/patch_core/archive_patch_core.cpp +125 -0
- package/cpp/patch_core/archive_patch_core.h +59 -0
- package/cpp/patch_core/patch_core.cpp +533 -0
- package/cpp/patch_core/patch_core.h +68 -0
- package/cpp/patch_core/patch_core_android.cpp +112 -0
- package/cpp/patch_core/state_core.cpp +110 -0
- package/cpp/patch_core/state_core.h +58 -0
- package/cpp/patch_core/tests/patch_core_test.cpp +473 -0
- package/cpp/patch_core/update_core_android.cpp +469 -0
- package/harmony/pushy.har +0 -0
- package/ios/RCTPushy/RCTPushy.mm +233 -143
- package/package.json +17 -15
- package/react-native-update.podspec +3 -0
- package/scripts/build-harmony-har.js +12 -0
- package/scripts/prepublish.ts +49 -3
- package/scripts/prune-host-stl.sh +6 -0
- package/scripts/test-patch-core.sh +39 -0
- package/src/client.ts +129 -76
- package/src/core.ts +2 -1
- package/src/endpoint.ts +171 -0
- package/src/utils.ts +40 -27
- package/android/jni/lzma/DOC/7zC.txt +0 -187
- package/android/jni/lzma/DOC/7zFormat.txt +0 -469
- package/android/jni/lzma/DOC/Methods.txt +0 -173
- package/android/jni/lzma/DOC/installer.txt +0 -166
- package/android/jni/lzma/DOC/lzma-history.txt +0 -446
- package/android/jni/lzma/DOC/lzma-sdk.txt +0 -357
- package/android/jni/lzma/DOC/lzma-specification.txt +0 -1176
- package/android/jni/lzma/DOC/lzma.txt +0 -328
- package/android/jni/lzma/bin/7zS2.sfx +0 -0
- package/android/jni/lzma/bin/7zS2con.sfx +0 -0
- package/android/jni/lzma/bin/7zSD.sfx +0 -0
- package/android/jni/lzma/bin/7zdec.exe +0 -0
- package/android/jni/lzma/bin/7zr.exe +0 -0
- package/android/jni/lzma/bin/installer/config.txt +0 -5
- package/android/jni/lzma/bin/installer/cr.bat +0 -5
- package/android/jni/lzma/bin/lzma.exe +0 -0
- package/android/jni/lzma/bin/x64/7zr.exe +0 -0
- package/error.js +0 -1609
- package/harmony/har-wrapper/AppScope/app.json5 +0 -8
- package/harmony/har-wrapper/build-profile.json5 +0 -35
- package/harmony/har-wrapper/hvigor/hvigor-config.json5 +0 -5
- package/harmony/har-wrapper/hvigorfile.ts +0 -6
- package/harmony/har-wrapper/oh-package.json5 +0 -4
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/.cmake/api/v1/reply/cache-v2-77b153ce45aba0ed28ef.json +0 -1415
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/.cmake/api/v1/reply/cmakeFiles-v1-b65a07793384e0ce3e08.json +0 -809
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/.cmake/api/v1/reply/codemodel-v2-ce0e89410afd8bf3a057.json +0 -60
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/.cmake/api/v1/reply/directory-.-Release-f5ebdc15457944623624.json +0 -14
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/.cmake/api/v1/reply/index-2026-03-18T12-50-36-0050.json +0 -89
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/.cmake/api/v1/reply/target-rnupdate-Release-267153624504c9c3ffdd.json +0 -222
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/.ninja_deps +0 -0
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/.ninja_log +0 -8
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/CMakeCache.txt +0 -415
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/CMakeFiles/3.28.2/CMakeCCompiler.cmake +0 -74
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/CMakeFiles/3.28.2/CMakeCXXCompiler.cmake +0 -85
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/CMakeFiles/3.28.2/CMakeDetermineCompilerABI_C.bin +0 -0
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/CMakeFiles/3.28.2/CMakeDetermineCompilerABI_CXX.bin +0 -0
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/CMakeFiles/3.28.2/CMakeSystem.cmake +0 -15
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/CMakeFiles/3.28.2/CompilerIdC/CMakeCCompilerId.c +0 -880
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/CMakeFiles/3.28.2/CompilerIdC/CMakeCCompilerId.o +0 -0
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/CMakeFiles/3.28.2/CompilerIdCXX/CMakeCXXCompilerId.cpp +0 -869
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/CMakeFiles/3.28.2/CompilerIdCXX/CMakeCXXCompilerId.o +0 -0
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/CMakeFiles/CMakeConfigureLog.yaml +0 -388
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/CMakeFiles/TargetDirectories.txt +0 -3
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/CMakeFiles/cmake.check_cache +0 -1
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/CMakeFiles/rnupdate.dir/__w/react-native-update/react-native-update/android/jni/HDiffPatch/file_for_patch.c.o +0 -0
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/CMakeFiles/rnupdate.dir/__w/react-native-update/react-native-update/android/jni/HDiffPatch/libHDiffPatch/HPatch/patch.c.o +0 -0
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/CMakeFiles/rnupdate.dir/__w/react-native-update/react-native-update/android/jni/hpatch.c.o +0 -0
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/CMakeFiles/rnupdate.dir/__w/react-native-update/react-native-update/android/jni/lzma/C/Lzma2Dec.c.o +0 -0
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/CMakeFiles/rnupdate.dir/__w/react-native-update/react-native-update/android/jni/lzma/C/LzmaDec.c.o +0 -0
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/CMakeFiles/rnupdate.dir/pushy.c.o +0 -0
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/CMakeFiles/rules.ninja +0 -64
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/additional_project_files.txt +0 -0
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/build.ninja +0 -206
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/build_file_index.txt +0 -1
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/cmake_install.cmake +0 -54
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/compile_commands.json +0 -38
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/configure_fingerprint.json +0 -1
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/hvigor_native_config.json +0 -1
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/metadata_generation_command.txt +0 -17
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/native_work_dir.txt +0 -1
- package/harmony/pushy/.cxx/default/default/release/arm64-v8a/output.log +0 -14
- package/harmony/pushy/.cxx/default/default/release/hvigor/arm64-v8a/summary.cmake +0 -0
- package/harmony/pushy/BuildProfile.ets +0 -17
- package/harmony/pushy/OAT.xml +0 -38
- package/harmony/pushy/README.md +0 -0
- package/harmony/pushy/build-profile.json5 +0 -15
- package/harmony/pushy/hvigor-plugin.ts +0 -34
- package/harmony/pushy/hvigorfile.ts +0 -1
- package/harmony/pushy/index.ets +0 -2
- package/harmony/pushy/oh-package-lock.json5 +0 -20
- package/harmony/pushy/oh-package.json5 +0 -13
- package/harmony/pushy/src/main/cpp/CMakeLists.txt +0 -51
- package/harmony/pushy/src/main/cpp/PushyPackage.h +0 -55
- package/harmony/pushy/src/main/cpp/PushyTurboModule.cpp +0 -142
- package/harmony/pushy/src/main/cpp/PushyTurboModule.h +0 -38
- package/harmony/pushy/src/main/cpp/pushy.c +0 -117
- package/harmony/pushy/src/main/cpp/pushy.h +0 -8
- package/harmony/pushy/src/main/ets/DownloadTask.ts +0 -570
- package/harmony/pushy/src/main/ets/DownloadTaskParams.ts +0 -19
- package/harmony/pushy/src/main/ets/EventHub.ts +0 -39
- package/harmony/pushy/src/main/ets/Logger.ts +0 -52
- package/harmony/pushy/src/main/ets/PushyFileJSBundleProvider.ets +0 -50
- package/harmony/pushy/src/main/ets/PushyPackage.ts +0 -22
- package/harmony/pushy/src/main/ets/PushyTurboModule.ts +0 -171
- package/harmony/pushy/src/main/ets/SaveFile.ts +0 -34
- package/harmony/pushy/src/main/ets/UpdateContext.ts +0 -262
- package/harmony/pushy/src/main/ets/UpdateModuleImpl.ts +0 -123
- package/harmony/pushy/src/main/module.json5 +0 -7
- package/harmony/pushy/src/main/resources/base/element/string.json +0 -8
- package/harmony/pushy/src/main/resources/en_US/element/string.json +0 -8
- package/harmony/pushy/src/main/resources/zh_CN/element/string.json +0 -8
- package/harmony/pushy/ts.ts +0 -3
- package/src/__tests__/core.test.ts +0 -103
- package/src/__tests__/utils.test.ts +0 -36
|
@@ -15,6 +15,10 @@ import java.util.concurrent.Executors;
|
|
|
15
15
|
import java.io.File;
|
|
16
16
|
|
|
17
17
|
public class UpdateContext {
|
|
18
|
+
static {
|
|
19
|
+
NativeUpdateCore.ensureLoaded();
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
private Context context;
|
|
19
23
|
private File rootDir;
|
|
20
24
|
private Executor executor;
|
|
@@ -22,11 +26,31 @@ public class UpdateContext {
|
|
|
22
26
|
public static boolean DEBUG = true;
|
|
23
27
|
private static ReactInstanceManager mReactInstanceManager;
|
|
24
28
|
private static boolean isUsingBundleUrl = false;
|
|
29
|
+
private static final int STATE_OP_SWITCH_VERSION = 1;
|
|
30
|
+
private static final int STATE_OP_MARK_SUCCESS = 2;
|
|
31
|
+
private static final int STATE_OP_ROLLBACK = 3;
|
|
32
|
+
private static final int STATE_OP_CLEAR_FIRST_TIME = 4;
|
|
33
|
+
private static final int STATE_OP_CLEAR_ROLLBACK_MARK = 5;
|
|
34
|
+
private static final int STATE_OP_RESOLVE_LAUNCH = 6;
|
|
25
35
|
|
|
26
36
|
// Singleton instance
|
|
27
37
|
private static UpdateContext sInstance;
|
|
28
38
|
private static final Object sLock = new Object();
|
|
29
39
|
|
|
40
|
+
private static native StateCoreResult syncStateWithBinaryVersion(
|
|
41
|
+
String packageVersion,
|
|
42
|
+
String buildTime,
|
|
43
|
+
StateCoreResult state
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
private static native StateCoreResult runStateCore(
|
|
47
|
+
int operation,
|
|
48
|
+
StateCoreResult state,
|
|
49
|
+
String stringArg,
|
|
50
|
+
boolean flagA,
|
|
51
|
+
boolean flagB
|
|
52
|
+
);
|
|
53
|
+
|
|
30
54
|
public UpdateContext(Context context) {
|
|
31
55
|
this.context = context;
|
|
32
56
|
this.executor = Executors.newSingleThreadExecutor();
|
|
@@ -41,21 +65,18 @@ public class UpdateContext {
|
|
|
41
65
|
|
|
42
66
|
String packageVersion = getPackageVersion();
|
|
43
67
|
String buildTime = getBuildTime();
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
boolean buildTimeChanged = storedBuildTime == null || !buildTime.equals(storedBuildTime);
|
|
52
|
-
|
|
53
|
-
if (packageVersionChanged || buildTimeChanged) {
|
|
68
|
+
StateCoreResult nextState = syncStateWithBinaryVersion(
|
|
69
|
+
packageVersion,
|
|
70
|
+
buildTime,
|
|
71
|
+
getStateSnapshot()
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
if (nextState.changed) {
|
|
54
75
|
// Execute cleanUp before clearing SharedPreferences to avoid race condition
|
|
55
76
|
this.cleanUp();
|
|
77
|
+
SharedPreferences.Editor editor = this.sp.edit();
|
|
56
78
|
editor.clear();
|
|
57
|
-
editor
|
|
58
|
-
editor.putString("buildTime", buildTime);
|
|
79
|
+
applyState(editor, nextState);
|
|
59
80
|
editor.apply();
|
|
60
81
|
}
|
|
61
82
|
}
|
|
@@ -144,19 +165,55 @@ public class UpdateContext {
|
|
|
144
165
|
|
|
145
166
|
private SharedPreferences sp;
|
|
146
167
|
|
|
168
|
+
private StateCoreResult getStateSnapshot() {
|
|
169
|
+
StateCoreResult state = new StateCoreResult();
|
|
170
|
+
state.packageVersion = sp.getString("packageVersion", null);
|
|
171
|
+
state.buildTime = sp.getString("buildTime", null);
|
|
172
|
+
state.currentVersion = sp.getString("currentVersion", null);
|
|
173
|
+
state.lastVersion = sp.getString("lastVersion", null);
|
|
174
|
+
state.firstTime = sp.getBoolean("firstTime", false);
|
|
175
|
+
state.firstTimeOk = sp.getBoolean("firstTimeOk", true);
|
|
176
|
+
state.rolledBackVersion = sp.getString("rolledBackVersion", null);
|
|
177
|
+
return state;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
private static void putNullableString(
|
|
181
|
+
SharedPreferences.Editor editor,
|
|
182
|
+
String key,
|
|
183
|
+
String value
|
|
184
|
+
) {
|
|
185
|
+
if (value == null) {
|
|
186
|
+
editor.remove(key);
|
|
187
|
+
} else {
|
|
188
|
+
editor.putString(key, value);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
private void applyState(SharedPreferences.Editor editor, StateCoreResult state) {
|
|
193
|
+
putNullableString(editor, "packageVersion", state.packageVersion);
|
|
194
|
+
putNullableString(editor, "buildTime", state.buildTime);
|
|
195
|
+
putNullableString(editor, "currentVersion", state.currentVersion);
|
|
196
|
+
putNullableString(editor, "lastVersion", state.lastVersion);
|
|
197
|
+
editor.putBoolean("firstTime", state.firstTime);
|
|
198
|
+
editor.putBoolean("firstTimeOk", state.firstTimeOk);
|
|
199
|
+
putNullableString(editor, "rolledBackVersion", state.rolledBackVersion);
|
|
200
|
+
}
|
|
201
|
+
|
|
147
202
|
public void switchVersion(String hash) {
|
|
148
203
|
if (!new File(rootDir, hash+"/index.bundlejs").exists()) {
|
|
149
204
|
throw new Error("Bundle version " + hash + " not found.");
|
|
150
205
|
}
|
|
151
|
-
|
|
206
|
+
StateCoreResult currentState = getStateSnapshot();
|
|
207
|
+
StateCoreResult nextState = runStateCore(
|
|
208
|
+
STATE_OP_SWITCH_VERSION,
|
|
209
|
+
currentState,
|
|
210
|
+
hash
|
|
211
|
+
,
|
|
212
|
+
false,
|
|
213
|
+
false
|
|
214
|
+
);
|
|
152
215
|
SharedPreferences.Editor editor = sp.edit();
|
|
153
|
-
editor
|
|
154
|
-
if (lastVersion != null && !lastVersion.equals(hash)) {
|
|
155
|
-
editor.putString("lastVersion", lastVersion);
|
|
156
|
-
}
|
|
157
|
-
editor.putBoolean("firstTime", true);
|
|
158
|
-
editor.putBoolean("firstTimeOk", false);
|
|
159
|
-
editor.putString("rolledBackVersion", null);
|
|
216
|
+
applyState(editor, nextState);
|
|
160
217
|
editor.apply();
|
|
161
218
|
}
|
|
162
219
|
|
|
@@ -184,13 +241,18 @@ public class UpdateContext {
|
|
|
184
241
|
|
|
185
242
|
public void markSuccess() {
|
|
186
243
|
if (!BuildConfig.DEBUG) {
|
|
244
|
+
StateCoreResult currentState = getStateSnapshot();
|
|
245
|
+
StateCoreResult nextState = runStateCore(
|
|
246
|
+
STATE_OP_MARK_SUCCESS,
|
|
247
|
+
currentState,
|
|
248
|
+
null,
|
|
249
|
+
false,
|
|
250
|
+
false
|
|
251
|
+
);
|
|
187
252
|
SharedPreferences.Editor editor = sp.edit();
|
|
188
|
-
editor
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if (lastVersion != null && !lastVersion.equals(curVersion)) {
|
|
192
|
-
editor.remove("lastVersion");
|
|
193
|
-
editor.remove("hash_" + lastVersion);
|
|
253
|
+
applyState(editor, nextState);
|
|
254
|
+
if (nextState.staleVersionToDelete != null) {
|
|
255
|
+
editor.remove("hash_" + nextState.staleVersionToDelete);
|
|
194
256
|
}
|
|
195
257
|
editor.apply();
|
|
196
258
|
|
|
@@ -199,16 +261,32 @@ public class UpdateContext {
|
|
|
199
261
|
}
|
|
200
262
|
|
|
201
263
|
public void clearFirstTime() {
|
|
264
|
+
StateCoreResult currentState = getStateSnapshot();
|
|
265
|
+
StateCoreResult nextState = runStateCore(
|
|
266
|
+
STATE_OP_CLEAR_FIRST_TIME,
|
|
267
|
+
currentState,
|
|
268
|
+
null,
|
|
269
|
+
false,
|
|
270
|
+
false
|
|
271
|
+
);
|
|
202
272
|
SharedPreferences.Editor editor = sp.edit();
|
|
203
|
-
editor
|
|
273
|
+
applyState(editor, nextState);
|
|
204
274
|
editor.apply();
|
|
205
275
|
|
|
206
276
|
this.cleanUp();
|
|
207
277
|
}
|
|
208
278
|
|
|
209
279
|
public void clearRollbackMark() {
|
|
280
|
+
StateCoreResult currentState = getStateSnapshot();
|
|
281
|
+
StateCoreResult nextState = runStateCore(
|
|
282
|
+
STATE_OP_CLEAR_ROLLBACK_MARK,
|
|
283
|
+
currentState,
|
|
284
|
+
null,
|
|
285
|
+
false,
|
|
286
|
+
false
|
|
287
|
+
);
|
|
210
288
|
SharedPreferences.Editor editor = sp.edit();
|
|
211
|
-
editor
|
|
289
|
+
applyState(editor, nextState);
|
|
212
290
|
editor.apply();
|
|
213
291
|
|
|
214
292
|
this.cleanUp();
|
|
@@ -251,17 +329,24 @@ public class UpdateContext {
|
|
|
251
329
|
|
|
252
330
|
public String getBundleUrl(String defaultAssetsUrl) {
|
|
253
331
|
isUsingBundleUrl = true;
|
|
254
|
-
|
|
332
|
+
StateCoreResult currentState = getStateSnapshot();
|
|
333
|
+
StateCoreResult launchState = runStateCore(
|
|
334
|
+
STATE_OP_RESOLVE_LAUNCH,
|
|
335
|
+
currentState,
|
|
336
|
+
null,
|
|
337
|
+
false,
|
|
338
|
+
false
|
|
339
|
+
);
|
|
340
|
+
if (launchState.didRollback || launchState.consumedFirstTime) {
|
|
341
|
+
SharedPreferences.Editor editor = sp.edit();
|
|
342
|
+
applyState(editor, launchState);
|
|
343
|
+
editor.apply();
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
String currentVersion = launchState.loadVersion;
|
|
255
347
|
if (currentVersion == null) {
|
|
256
348
|
return defaultAssetsUrl;
|
|
257
349
|
}
|
|
258
|
-
// Test should rollback.
|
|
259
|
-
if (!sp.getBoolean("firstTime", false)) {
|
|
260
|
-
if (!sp.getBoolean("firstTimeOk", true)) {
|
|
261
|
-
// Not firstTime, but not ok, so we roll back.
|
|
262
|
-
currentVersion = this.rollBack();
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
350
|
|
|
266
351
|
while (currentVersion != null) {
|
|
267
352
|
File bundleFile = new File(rootDir, currentVersion+"/index.bundlejs");
|
|
@@ -277,20 +362,18 @@ public class UpdateContext {
|
|
|
277
362
|
}
|
|
278
363
|
|
|
279
364
|
private String rollBack() {
|
|
280
|
-
|
|
281
|
-
|
|
365
|
+
StateCoreResult currentState = getStateSnapshot();
|
|
366
|
+
StateCoreResult nextState = runStateCore(
|
|
367
|
+
STATE_OP_ROLLBACK,
|
|
368
|
+
currentState,
|
|
369
|
+
null,
|
|
370
|
+
false,
|
|
371
|
+
false
|
|
372
|
+
);
|
|
282
373
|
SharedPreferences.Editor editor = sp.edit();
|
|
283
|
-
|
|
284
|
-
editor.remove("currentVersion");
|
|
285
|
-
} else {
|
|
286
|
-
editor.remove("lastVersion");
|
|
287
|
-
editor.putString("currentVersion", lastVersion);
|
|
288
|
-
}
|
|
289
|
-
editor.putBoolean("firstTimeOk", true);
|
|
290
|
-
editor.putBoolean("firstTime", false);
|
|
291
|
-
editor.putString("rolledBackVersion", currentVersion);
|
|
374
|
+
applyState(editor, nextState);
|
|
292
375
|
editor.apply();
|
|
293
|
-
return
|
|
376
|
+
return nextState.currentVersion;
|
|
294
377
|
}
|
|
295
378
|
|
|
296
379
|
private void cleanUp() {
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#include "archive_patch_core.h"
|
|
2
|
+
|
|
3
|
+
namespace pushy {
|
|
4
|
+
namespace archive_patch {
|
|
5
|
+
namespace {
|
|
6
|
+
|
|
7
|
+
constexpr const char* kManifestEntryName = "__diff.json";
|
|
8
|
+
bool HasEntry(const std::vector<std::string>& entry_names, const std::string& name) {
|
|
9
|
+
for (const std::string& entry_name : entry_names) {
|
|
10
|
+
if (entry_name == name) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
} // namespace
|
|
18
|
+
|
|
19
|
+
EntryAction ClassifyEntry(
|
|
20
|
+
ArchivePatchType type,
|
|
21
|
+
const std::string& entry_name) {
|
|
22
|
+
if (type == ArchivePatchType::kFull) {
|
|
23
|
+
return EntryAction::kExtract;
|
|
24
|
+
}
|
|
25
|
+
return entry_name == kManifestEntryName ? EntryAction::kSkip : EntryAction::kExtract;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
patch::Status BuildArchivePatchPlan(
|
|
29
|
+
ArchivePatchType type,
|
|
30
|
+
const patch::PatchManifest& manifest,
|
|
31
|
+
const std::vector<std::string>& entry_names,
|
|
32
|
+
ArchivePatchPlan* out_plan,
|
|
33
|
+
const std::string& bundle_patch_entry_name) {
|
|
34
|
+
if (out_plan == nullptr) {
|
|
35
|
+
return patch::Status::Error("Archive patch plan output is required");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
patch::Status manifest_status = patch::ValidateManifest(manifest);
|
|
39
|
+
if (!manifest_status.ok) {
|
|
40
|
+
return manifest_status;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
out_plan->type = type;
|
|
44
|
+
out_plan->manifest = manifest;
|
|
45
|
+
out_plan->merge_source_subdir.clear();
|
|
46
|
+
out_plan->enable_merge = false;
|
|
47
|
+
|
|
48
|
+
switch (type) {
|
|
49
|
+
case ArchivePatchType::kFull:
|
|
50
|
+
return patch::Status::Ok();
|
|
51
|
+
case ArchivePatchType::kPatchFromPackage:
|
|
52
|
+
case ArchivePatchType::kPatchFromPpk:
|
|
53
|
+
if (!HasEntry(entry_names, kManifestEntryName)) {
|
|
54
|
+
return patch::Status::Error("diff.json not found");
|
|
55
|
+
}
|
|
56
|
+
if (!HasEntry(entry_names, bundle_patch_entry_name)) {
|
|
57
|
+
return patch::Status::Error("bundle patch not found");
|
|
58
|
+
}
|
|
59
|
+
out_plan->merge_source_subdir =
|
|
60
|
+
type == ArchivePatchType::kPatchFromPackage ? "assets" : "";
|
|
61
|
+
out_plan->enable_merge = true;
|
|
62
|
+
return patch::Status::Ok();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return patch::Status::Error("Unknown archive patch type");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
patch::Status BuildCopyGroups(
|
|
69
|
+
const patch::PatchManifest& manifest,
|
|
70
|
+
std::vector<CopyGroup>* out_groups) {
|
|
71
|
+
if (out_groups == nullptr) {
|
|
72
|
+
return patch::Status::Error("Copy groups output is required");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
patch::Status manifest_status = patch::ValidateManifest(manifest);
|
|
76
|
+
if (!manifest_status.ok) {
|
|
77
|
+
return manifest_status;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
out_groups->clear();
|
|
81
|
+
for (const patch::CopyOperation& copy : manifest.copies) {
|
|
82
|
+
bool appended = false;
|
|
83
|
+
for (CopyGroup& group : *out_groups) {
|
|
84
|
+
if (group.from == copy.from) {
|
|
85
|
+
group.to_paths.push_back(copy.to);
|
|
86
|
+
appended = true;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (!appended) {
|
|
91
|
+
CopyGroup group;
|
|
92
|
+
group.from = copy.from;
|
|
93
|
+
group.to_paths.push_back(copy.to);
|
|
94
|
+
out_groups->push_back(group);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return patch::Status::Ok();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
patch::Status BuildFileSourcePatchOptions(
|
|
102
|
+
const ArchivePatchPlan& plan,
|
|
103
|
+
const std::string& source_root,
|
|
104
|
+
const std::string& target_root,
|
|
105
|
+
const std::string& origin_bundle_path,
|
|
106
|
+
const std::string& bundle_patch_path,
|
|
107
|
+
const std::string& bundle_output_path,
|
|
108
|
+
patch::FileSourcePatchOptions* out_options) {
|
|
109
|
+
if (out_options == nullptr) {
|
|
110
|
+
return patch::Status::Error("Patch options output is required");
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
out_options->manifest = plan.manifest;
|
|
114
|
+
out_options->source_root = source_root;
|
|
115
|
+
out_options->target_root = target_root;
|
|
116
|
+
out_options->origin_bundle_path = origin_bundle_path;
|
|
117
|
+
out_options->bundle_patch_path = bundle_patch_path;
|
|
118
|
+
out_options->bundle_output_path = bundle_output_path;
|
|
119
|
+
out_options->merge_source_subdir = plan.merge_source_subdir;
|
|
120
|
+
out_options->enable_merge = plan.enable_merge;
|
|
121
|
+
return patch::Status::Ok();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
} // namespace archive_patch
|
|
125
|
+
} // namespace pushy
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
#include <vector>
|
|
5
|
+
|
|
6
|
+
#include "patch_core.h"
|
|
7
|
+
|
|
8
|
+
namespace pushy {
|
|
9
|
+
namespace archive_patch {
|
|
10
|
+
|
|
11
|
+
enum class ArchivePatchType {
|
|
12
|
+
kFull = 1,
|
|
13
|
+
kPatchFromPackage = 2,
|
|
14
|
+
kPatchFromPpk = 3,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
enum class EntryAction {
|
|
18
|
+
kSkip = 0,
|
|
19
|
+
kExtract = 1,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
struct CopyGroup {
|
|
23
|
+
std::string from;
|
|
24
|
+
std::vector<std::string> to_paths;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
struct ArchivePatchPlan {
|
|
28
|
+
ArchivePatchType type = ArchivePatchType::kFull;
|
|
29
|
+
patch::PatchManifest manifest;
|
|
30
|
+
std::string merge_source_subdir;
|
|
31
|
+
bool enable_merge = false;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
EntryAction ClassifyEntry(
|
|
35
|
+
ArchivePatchType type,
|
|
36
|
+
const std::string& entry_name);
|
|
37
|
+
|
|
38
|
+
patch::Status BuildArchivePatchPlan(
|
|
39
|
+
ArchivePatchType type,
|
|
40
|
+
const patch::PatchManifest& manifest,
|
|
41
|
+
const std::vector<std::string>& entry_names,
|
|
42
|
+
ArchivePatchPlan* out_plan,
|
|
43
|
+
const std::string& bundle_patch_entry_name = "index.bundlejs.patch");
|
|
44
|
+
|
|
45
|
+
patch::Status BuildCopyGroups(
|
|
46
|
+
const patch::PatchManifest& manifest,
|
|
47
|
+
std::vector<CopyGroup>* out_groups);
|
|
48
|
+
|
|
49
|
+
patch::Status BuildFileSourcePatchOptions(
|
|
50
|
+
const ArchivePatchPlan& plan,
|
|
51
|
+
const std::string& source_root,
|
|
52
|
+
const std::string& target_root,
|
|
53
|
+
const std::string& origin_bundle_path,
|
|
54
|
+
const std::string& bundle_patch_path,
|
|
55
|
+
const std::string& bundle_output_path,
|
|
56
|
+
patch::FileSourcePatchOptions* out_options);
|
|
57
|
+
|
|
58
|
+
} // namespace archive_patch
|
|
59
|
+
} // namespace pushy
|