mirror of
https://github.com/morluto/rea.git
synced 2026-12-05 14:31:22 +00:00
refactor(pyinstaller): share PYZ container projection (#15485)
This commit is contained in:
1 parent
f2e7bb43d7
commit
e233afbe50
1 file changed
+35
-67
@@ -129,74 +129,42 @@ export const projectPyzContainer = (
|
||||
pathDialect: CarrierPathDialect,
|
||||
): PyInstallerMember => {
|
||||
const { archive } = image;
|
||||
const path = canonicalMemberPath(entry.name, pathDialect);
|
||||
const byteOffset = sourceByteOffset(entry, archiveStart);
|
||||
const limitations: string[] = [];
|
||||
if (archive.kind === "opaque")
|
||||
return {
|
||||
entry: projectEntry({
|
||||
path,
|
||||
declaredSize: entry.uncompressedSize,
|
||||
compressedSize: entry.compressedSize,
|
||||
byteOffset,
|
||||
// Legacy encryption applies to inner payloads, never the PYZ image.
|
||||
encrypted: false,
|
||||
limitations: [
|
||||
...limitations,
|
||||
archive.limitation,
|
||||
...(encrypted
|
||||
? ["PYZ entries are encrypted and were not decoded."]
|
||||
: []),
|
||||
],
|
||||
adapterKey: `carchive:${String(entry.index)}:${entry.name}`,
|
||||
formatMetadata: cArchiveEntryMetadata(
|
||||
entry,
|
||||
undefined,
|
||||
archive,
|
||||
encrypted,
|
||||
),
|
||||
}),
|
||||
read:
|
||||
entry.compressionFlag === 1
|
||||
? {
|
||||
kind: "pyz",
|
||||
handle: image.handle,
|
||||
offset: image.start,
|
||||
length: entry.uncompressedSize,
|
||||
compressed: false,
|
||||
uncompressedSize: entry.uncompressedSize,
|
||||
header: undefined,
|
||||
}
|
||||
: {
|
||||
kind: "carchive",
|
||||
archiveStart,
|
||||
source: entry,
|
||||
header: undefined,
|
||||
},
|
||||
};
|
||||
const opaque = archive.kind === "opaque";
|
||||
const container = projectEntry({
|
||||
path: canonicalMemberPath(entry.name, pathDialect),
|
||||
kind: opaque ? "file" : "directory",
|
||||
declaredSize: entry.uncompressedSize,
|
||||
compressedSize: entry.compressedSize,
|
||||
byteOffset: sourceByteOffset(entry, archiveStart),
|
||||
// Legacy encryption applies to inner payloads, never the PYZ image.
|
||||
encrypted: false,
|
||||
limitations: [
|
||||
opaque ? archive.limitation : `PyInstaller PYZ sha256 ${archive.sha256}.`,
|
||||
...(encrypted ? ["PYZ entries are encrypted and were not decoded."] : []),
|
||||
],
|
||||
adapterKey: `carchive:${String(entry.index)}:${entry.name}`,
|
||||
formatMetadata: cArchiveEntryMetadata(entry, undefined, archive, encrypted),
|
||||
});
|
||||
if (!opaque) return { entry: container, read: undefined };
|
||||
return {
|
||||
entry: projectEntry({
|
||||
path,
|
||||
kind: "directory",
|
||||
declaredSize: entry.uncompressedSize,
|
||||
compressedSize: entry.compressedSize,
|
||||
byteOffset,
|
||||
limitations: [
|
||||
...limitations,
|
||||
`PyInstaller PYZ sha256 ${archive.sha256}.`,
|
||||
...(encrypted
|
||||
? ["PYZ entries are encrypted and were not decoded."]
|
||||
: []),
|
||||
],
|
||||
adapterKey: `carchive:${String(entry.index)}:${entry.name}`,
|
||||
formatMetadata: cArchiveEntryMetadata(
|
||||
entry,
|
||||
undefined,
|
||||
archive,
|
||||
encrypted,
|
||||
),
|
||||
}),
|
||||
read: undefined,
|
||||
entry: container,
|
||||
read:
|
||||
entry.compressionFlag === 1
|
||||
? {
|
||||
kind: "pyz",
|
||||
handle: image.handle,
|
||||
offset: image.start,
|
||||
length: entry.uncompressedSize,
|
||||
compressed: false,
|
||||
uncompressedSize: entry.uncompressedSize,
|
||||
header: undefined,
|
||||
}
|
||||
: {
|
||||
kind: "carchive",
|
||||
archiveStart,
|
||||
source: entry,
|
||||
header: undefined,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user