Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ private void doFullPatch() throws IOException {
}
}

if (params.targetFile.exists()) {
params.targetFile.delete();
}
}

private void doPatchFromApk() throws IOException, JSONException {
Expand Down Expand Up @@ -300,6 +303,9 @@ private void doPatchFromApk() throws IOException, JSONException {
}

bundledResourceCopier.copyFromResource(copyList, contents.copyCrcs);
if (params.targetFile.exists()) {
params.targetFile.delete();
}
}

private void doPatchFromPpk() throws IOException, JSONException {
Expand All @@ -326,15 +332,17 @@ private void doPatchFromPpk() throws IOException, JSONException {
contents.copyTos.toArray(new String[0]),
contents.deletes.toArray(new String[0])
);

if (params.targetFile.exists()) {
params.targetFile.delete();
}
}

private void doCleanUp() {
cleanupOldEntries(
params.unzipDirectory.getAbsolutePath(),
params.hash,
params.originHash,
7
3
);
}

Expand Down
63 changes: 46 additions & 17 deletions harmony/pushy/src/main/ets/DownloadTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,13 @@ export class DownloadTask {
await this.downloadFile(params);
await this.recreateDirectory(params.unzipDirectory);
await zlib.decompressFile(params.targetFile, params.unzipDirectory);
try {
if (fileIo.accessSync(params.targetFile)) {
await fileIo.unlink(params.targetFile);
}
} catch (e) {
console.error('Failed to delete temporary zip file after decompression:', e);
}
}

private async doPatchFromApp(params: DownloadTaskParams): Promise<void> {
Expand Down Expand Up @@ -484,6 +491,13 @@ export class DownloadTask {
),
params.unzipDirectory,
);
try {
if (fileIo.accessSync(params.targetFile)) {
await fileIo.unlink(params.targetFile);
}
} catch (e) {
console.error('Failed to delete temporary zip file after patching:', e);
}
}

private async doPatchFromPpk(params: DownloadTaskParams): Promise<void> {
Expand Down Expand Up @@ -517,6 +531,13 @@ export class DownloadTask {
enableMerge: plan.enableMerge,
});
console.info('Patch from PPK completed');
try {
if (fileIo.accessSync(params.targetFile)) {
await fileIo.unlink(params.targetFile);
}
} catch (e) {
console.error('Failed to delete temporary patch file after patching:', e);
}
}

private async copyFromResource(
Expand Down Expand Up @@ -548,27 +569,35 @@ export class DownloadTask {
parentDirs.map(dir => this.ensureDirectory(dir)),
);
await Promise.all(
targets.map(target => this.writeFileContent(target, mediaBuffer.buffer)),
targets.map(target => this.writeFileContent(target, mediaBuffer)),
);
continue;
}
const fromContent = await resourceManager.getRawFd(currentFrom);
const [firstTarget, ...restTargets] = targets;
const parentDirs = [
...new Set(
targets.map(t => t.substring(0, t.lastIndexOf('/'))).filter(Boolean),
),
];
await Promise.all(
parentDirs.map(dir => this.ensureDirectory(dir))
);
if (fileIo.accessSync(firstTarget)) {
await fileIo.unlink(firstTarget);
try {
const [firstTarget, ...restTargets] = targets;
const parentDirs = [
...new Set(
targets.map(t => t.substring(0, t.lastIndexOf('/'))).filter(Boolean),
),
];
await Promise.all(
parentDirs.map(dir => this.ensureDirectory(dir))
);
if (fileIo.accessSync(firstTarget)) {
await fileIo.unlink(firstTarget);
}
saveFileToSandbox(fromContent, firstTarget);
await Promise.all(
restTargets.map(target => this.copySandboxFile(firstTarget, target)),
);
} finally {
try {
await resourceManager.closeRawFd(currentFrom);
} catch (closeError) {
console.error(`Failed to close raw fd for ${currentFrom}:`, closeError);
}
}
saveFileToSandbox(fromContent, firstTarget);
await Promise.all(
restTargets.map(target => this.copySandboxFile(firstTarget, target)),
);
}
} catch (error) {
error.message =
Expand All @@ -589,7 +618,7 @@ export class DownloadTask {
params.unzipDirectory,
params.hash || '',
params.originHash || '',
7,
3,
);
} catch (error) {
error.message = 'Cleanup failed:' + error.message;
Expand Down
2 changes: 1 addition & 1 deletion harmony/pushy/src/main/ets/UpdateContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ export class UpdateContext {
this.rootDir,
state.currentVersion || '',
state.lastVersion || '',
7,
3,
);
}

Expand Down
2 changes: 1 addition & 1 deletion ios/RCTPushy/RCTPushy.mm
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ - (void)clearInvalidFiles
PushyToStdString(downloadDir),
state.current_version,
state.last_version,
7
3
);
if (!status.ok) {
RCTLogWarn(@"Pushy cleanup error: %s", status.message.c_str());
Expand Down
Loading