Disable default stripping of ZIP archive
Signed-off-by: Bartosz Nadworny <bartosz.nadworny@zurich.ch>
This commit is contained in:
committed by
Bartosz Nadworny
parent
8576195e38
commit
a365f1faf4
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/backend-common': patch
|
||||
---
|
||||
|
||||
Disable stripping of ZIP archive
|
||||
@@ -38,6 +38,7 @@ export class ZipArchiveResponse implements ReadTreeResponse {
|
||||
private readonly workDir: string,
|
||||
public readonly etag: string,
|
||||
private readonly filter?: (path: string, info: { size: number }) => boolean,
|
||||
private readonly stripFirstDirectoryFromPath?: boolean,
|
||||
) {
|
||||
if (subPath) {
|
||||
if (!subPath.endsWith('/')) {
|
||||
@@ -67,7 +68,7 @@ export class ZipArchiveResponse implements ReadTreeResponse {
|
||||
}
|
||||
|
||||
private shouldBeIncluded(entry: Entry): boolean {
|
||||
const strippedPath = stripFirstDirectoryFromPath(entry.path);
|
||||
const strippedPath = this.stripFirstDirectoryFromPath ? stripFirstDirectoryFromPath(entry.path) : entry.path;
|
||||
|
||||
if (this.subPath) {
|
||||
if (!strippedPath.startsWith(this.subPath)) {
|
||||
@@ -99,7 +100,7 @@ export class ZipArchiveResponse implements ReadTreeResponse {
|
||||
|
||||
if (this.shouldBeIncluded(entry)) {
|
||||
files.push({
|
||||
path: this.getInnerPath(stripFirstDirectoryFromPath(entry.path)),
|
||||
path: this.getInnerPath(this.stripFirstDirectoryFromPath ? stripFirstDirectoryFromPath(entry.path) : entry.path),
|
||||
content: () => entry.buffer(),
|
||||
});
|
||||
} else {
|
||||
@@ -148,7 +149,7 @@ export class ZipArchiveResponse implements ReadTreeResponse {
|
||||
// as a zip can have files with directories without directory entries
|
||||
if (entry.type === 'File' && this.shouldBeIncluded(entry)) {
|
||||
const entryPath = this.getInnerPath(
|
||||
stripFirstDirectoryFromPath(entry.path),
|
||||
this.stripFirstDirectoryFromPath ? stripFirstDirectoryFromPath(entry.path) : entry.path,
|
||||
);
|
||||
const dirname = platformPath.dirname(entryPath);
|
||||
if (dirname) {
|
||||
|
||||
Reference in New Issue
Block a user