Skip to content

Commit e0f5e99

Browse files
committed
Fixed issue where additional package paths would add duplicate files
1 parent ba377af commit e0f5e99

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

app/exec/extension/_lib/vsix-manifest-builder.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -794,22 +794,29 @@ export class VsixManifestBuilder extends ManifestBuilder {
794794
});
795795
}
796796
return contentTypePromise.then(() => {
797+
let seenPartNames = new Set();
797798
Object.keys(this.files).forEach(filePath => {
798799
if (this.files[filePath].contentType) {
800+
let partName = "/" + toZipItemName(this.files[filePath].partName);
799801
contentTypes.Types.Override.push({
800802
$: {
801803
ContentType: this.files[filePath].contentType,
802-
PartName: "/" + toZipItemName(this.files[filePath].partName),
804+
PartName: partName,
803805
},
804806
});
807+
seenPartNames.add(partName);
805808
if ((this.files[filePath] as any)._additionalPackagePaths) {
806-
for (const additionalPath of (this.files[filePath] as any)._additionalPackagePaths) {
807-
contentTypes.Types.Override.push({
808-
$: {
809-
ContentType: this.files[filePath].contentType,
810-
PartName: "/" + toZipItemName(additionalPath),
811-
},
812-
});
809+
for (const additionalPath of (this.files[filePath] as any)._additionalPackagePaths) {
810+
let additionalPartName = "/" + toZipItemName(additionalPath);
811+
if (!seenPartNames.has(additionalPartName)) {
812+
contentTypes.Types.Override.push({
813+
$: {
814+
ContentType: this.files[filePath].contentType,
815+
PartName: additionalPartName,
816+
},
817+
});
818+
seenPartNames.add(additionalPartName);
819+
}
813820
}
814821
}
815822
}

app/exec/extension/_lib/vsix-writer.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ export class VsixWriter {
150150
let vsix = new zip();
151151

152152
let builderPromises: Promise<void>[] = [];
153+
let seenPartNames = new Set();
153154
this.manifestBuilders.forEach(builder => {
154155
// Avoid the error EMFILE: too many open files
155156
const addPackageFilesBatch = (
@@ -184,18 +185,28 @@ export class VsixWriter {
184185
if (!builder.files[path].content) {
185186
let readFilePromise = promisify(readFile)(path).then(result => {
186187
vsix.file(itemName, result);
188+
seenPartNames.add(itemName);
187189
if ((builder.files[path] as any)._additionalPackagePaths) {
188190
for (const p of (builder.files[path] as any)._additionalPackagePaths) {
189-
vsix.file(p, result);
191+
let additionalItemName = toZipItemName(p);
192+
if (!seenPartNames.has(additionalItemName)) {
193+
vsix.file(additionalItemName, result);
194+
seenPartNames.add(additionalItemName);
195+
}
190196
}
191197
}
192198
});
193199
readFilePromises.push(readFilePromise);
194200
} else {
195201
vsix.file(itemName, builder.files[path].content);
202+
seenPartNames.add(itemName);
196203
if ((builder.files[path] as any)._additionalPackagePaths) {
197204
for (const p of (builder.files[path] as any)._additionalPackagePaths) {
198-
vsix.file(p, builder.files[path].content);
205+
let additionalItemName = toZipItemName(p);
206+
if (!seenPartNames.has(additionalItemName)) {
207+
vsix.file(additionalItemName, builder.files[path].content);
208+
seenPartNames.add(additionalItemName);
209+
}
199210
}
200211
}
201212
readFilePromises.push(Promise.resolve<void>(null));

0 commit comments

Comments
 (0)