Skip to content

Commit 21471a6

Browse files
Read storage block offsets from the archive BlocksInfo
The v9 format design changed: instead of a kArchiveBlockPaddingBetweenChunks flag telling readers to round each block's offset up to a 16 byte boundary, each StorageBlock now serializes a UInt64 offset giving where its stored bytes start, relative to the start of the data section. The writer is then free to change its padding policy without another format bump, and the reader no longer needs the "streamed blocks are not padded, chunk blocks are" special case. Parse that offset as the fourth field of each block record, after Flags, when the signature is UnityFS and the version is 9 or later. Version 8 and earlier store their blocks contiguously, so their offsets are still accumulated from the compressed sizes. A v9 archive whose blocks are out of order or overlapping is rejected, matching the native reader. The archive flag is gone from the format, so it is gone from the flag table too, and `archive info` now derives the padding total from the stored offsets. Regenerates the LZ4 reference bundles in the new format. Their SerializedFiles are version 26, which the C# metadata parser does not read yet (issue #130), so `analyze` and `serialized-file` cannot inspect this data; the `archive` commands and `dump` can. The mp3 .meta files gain explicit importer settings, which the project needs in order to build with a 6.7 editor.
1 parent 6da4de6 commit 21471a6

24 files changed

Lines changed: 187 additions & 94 deletions

‎Archive/ArchiveTool.cs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,14 @@ public static int PrintSummary(FileInfo filename, OutputFormat format)
163163
uncompressedDataSize += block.UncompressedSize;
164164
}
165165

166-
// The data section can be larger than the sum of the blocks, because of the alignment
167-
// padding that separates chunk-based blocks (the BlockPaddingBetweenChunks flag).
166+
// The data section can be larger than the sum of the blocks, because the writer may leave
167+
// padding between them. Only version 9 and later record where each block starts, so this is
168+
// the only version where padding is detectable (and where it is currently written).
168169
long paddingSize = 0;
169170
if (blocks.Length > 0)
170171
{
171172
var lastBlock = blocks[blocks.Length - 1];
172-
long dataSectionSize = lastBlock.FileOffset + lastBlock.CompressedSize - ArchiveDetector.GetDataOffset(header);
173-
paddingSize = dataSectionSize - dataSize;
173+
paddingSize = lastBlock.Offset + lastBlock.CompressedSize - dataSize;
174174
}
175175

176176
// Determine the compression algorithm by finding the first block that uses compression.
@@ -280,7 +280,6 @@ static readonly (uint bit, string name)[] KnownArchiveFlags =
280280
(ArchiveFlags.BlocksInfoAtTheEnd, "BlocksInfoAtTheEnd"),
281281
(ArchiveFlags.OldWebPluginCompatibility, "OldWebPluginCompatibility"),
282282
(ArchiveFlags.BlockInfoNeedPaddingAtStart, "BlockInfoNeedPaddingAtStart"),
283-
(ArchiveFlags.BlockPaddingBetweenChunks, "BlockPaddingBetweenChunks"),
284283
};
285284

286285
static string[] GetArchiveFlagNames(uint flagBits)

‎TestCommon/Data/LeadingEdgeBuilds/AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The LeadingEdge build scripts regenerate this folder directly, so to update it,
77
## Layout
88

99
* `AssetBundles/` - the AssetBundle build: one bundle per asset (named after the asset) plus the `AssetBundles` manifest bundle. LZMA compressed, so each archive has a single data block.
10-
* `AssetBundlesLz4/` - the same bundle layout built with chunk-based (LZ4) compression, giving archives with multiple data blocks separated by alignment padding (archive format version 9).
10+
* `AssetBundlesLz4/` - the same bundle layout built with chunk-based (LZ4) compression, giving archives with multiple data blocks. The writer leaves padding between the blocks, so these exercise the `StorageBlock.Offset` field added in archive format version 9.
1111
* `ContentDirectory/` - the Content Directory build: content (`.cf`) files, `.resource` files and the build manifest.
1212
* `BuildReport-AssetBundles/LastBuild.buildreport` - the AssetBundle build report.
1313
* `BuildReport-ContentDirectory/` - the Content Directory build report folder, including `ContentLayout.json`.
144 Bytes
Binary file not shown.

‎TestCommon/Data/LeadingEdgeBuilds/AssetBundlesLz4/6.manifest‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
ManifestFileVersion: 0
2-
UnityVersion: 6000.7.0a6
3-
CRC: 1054287113
2+
UnityVersion: 6000.7.0b1
3+
CRC: 2778854771
44
Hashes:
55
AssetFileHash:
66
serializedVersion: 2
7-
Hash: ef4548464eae98b6ab651c92a869edc9
7+
Hash: a19e41b950fe653a3177d32160af00b9
88
TypeTreeHash:
99
serializedVersion: 2
1010
Hash: 9a2ca7bdbd1871f7131daf57de908e0c
1111
IncrementalBuildHash:
1212
serializedVersion: 2
13-
Hash: 818e83165880f042a3252a52b336d06a
13+
Hash: 929d8f9d46e767e1fc66294cd024c1fa
1414
HashAppended: 0
1515
ClassTypes:
1616
- Class: 83
288 Bytes
Binary file not shown.

‎TestCommon/Data/LeadingEdgeBuilds/AssetBundlesLz4/AssetBundlesLz4.manifest‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ManifestFileVersion: 0
2-
UnityVersion: 6000.7.0a6
3-
CRC: 2935431312
2+
UnityVersion: 6000.7.0b1
3+
CRC: 318228433
44
HashAppended: 0
55
AssetBundleManifest:
66
AssetBundleInfos:
160 Bytes
Binary file not shown.

‎TestCommon/Data/LeadingEdgeBuilds/AssetBundlesLz4/a.manifest‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
ManifestFileVersion: 0
2-
UnityVersion: 6000.7.0a6
3-
CRC: 1988020392
2+
UnityVersion: 6000.7.0b1
3+
CRC: 3846767907
44
Hashes:
55
AssetFileHash:
66
serializedVersion: 2
7-
Hash: 6175fa89f0b4cfd7cc433b0b143ab713
7+
Hash: a408b749397654c01bfaa7832600a856
88
TypeTreeHash:
99
serializedVersion: 2
1010
Hash: 9a2ca7bdbd1871f7131daf57de908e0c
1111
IncrementalBuildHash:
1212
serializedVersion: 2
13-
Hash: ac9603f3b25ca1814eb4841392a9ff7e
13+
Hash: aeb2216eeb5ccfe1cb3f81e62f704746
1414
HashAppended: 0
1515
ClassTypes:
1616
- Class: 83
240 Bytes
Binary file not shown.

‎TestCommon/Data/LeadingEdgeBuilds/AssetBundlesLz4/assetbundleroot.manifest‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
ManifestFileVersion: 0
2-
UnityVersion: 6000.7.0a6
3-
CRC: 4203871746
2+
UnityVersion: 6000.7.0b1
3+
CRC: 408809727
44
Hashes:
55
AssetFileHash:
66
serializedVersion: 2
7-
Hash: 8ae6ceb771f9c15f2dde5117d3f67798
7+
Hash: f0b4981a1d1b8cf8a1bb7d53527a4e07
88
TypeTreeHash:
99
serializedVersion: 2
10-
Hash: e4c92e7ce30487f41e62ec475c399971
10+
Hash: 819240184df2798191fd853444ad58c4
1111
IncrementalBuildHash:
1212
serializedVersion: 2
13-
Hash: 00f65fc945d785da9075745396600fe2
13+
Hash: cf13ad57198a935f56c518df40c037d0
1414
HashAppended: 0
1515
ClassTypes:
1616
- Class: 114

0 commit comments

Comments
 (0)