Skip to content

Commit e9d5598

Browse files
authored
[VSC-1539] Fix scenario for partial encryption (#1373)
* Fix scenario for partial encryption * Fix partial encryption Move unencrypted files at the beginning * Rerun workflow
1 parent 009190b commit e9d5598

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

src/flash/flashTask.ts

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,28 @@ export class FlashTask {
292292
this.model.flashSections &&
293293
this.model.flashSections.length === encryptedFlashSections.length
294294
) {
295+
// If all files need encryption, then use --encrypt flag
295296
flasherArgs.push("--encrypt");
297+
// Add all files
298+
for (const flashFile of this.model.flashSections) {
299+
let binPath = replacePathSep
300+
? flashFile.binFilePath.replace(/\//g, "\\")
301+
: flashFile.binFilePath;
302+
flasherArgs.push(flashFile.address, binPath);
303+
}
296304
} else {
305+
// If only some files need encryption, handle them separately
306+
// First add all unencrypted files normally
307+
const unencryptedSections = this.model.flashSections.filter(
308+
(section) => !section.encrypted
309+
);
310+
for (const flashFile of unencryptedSections) {
311+
let binPath = replacePathSep
312+
? flashFile.binFilePath.replace(/\//g, "\\")
313+
: flashFile.binFilePath;
314+
flasherArgs.push(flashFile.address, binPath);
315+
}
316+
// Then add encrypted files after the --encrypt-files flag
297317
flasherArgs.push("--encrypt-files");
298318
for (const flashFile of encryptedFlashSections) {
299319
let binPath = replacePathSep
@@ -302,12 +322,14 @@ export class FlashTask {
302322
flasherArgs.push(flashFile.address, binPath);
303323
}
304324
}
305-
}
306-
for (const flashFile of this.model.flashSections) {
307-
let binPath = replacePathSep
308-
? flashFile.binFilePath.replace(/\//g, "\\")
309-
: flashFile.binFilePath;
310-
flasherArgs.push(flashFile.address, binPath);
325+
} else {
326+
// No encryption needed, just add all files.
327+
for (const flashFile of this.model.flashSections) {
328+
let binPath = replacePathSep
329+
? flashFile.binFilePath.replace(/\//g, "\\")
330+
: flashFile.binFilePath;
331+
flasherArgs.push(flashFile.address, binPath);
332+
}
311333
}
312334

313335
return flasherArgs;

0 commit comments

Comments
 (0)