isomorphic-git 1.37.2 → 1.37.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4037,12 +4037,13 @@ class GitPackIndex {
4037
4037
  0b1100000: 'ofs_delta',
4038
4038
  0b1110000: 'ref_delta',
4039
4039
  };
4040
- if (!this.pack) {
4040
+ const pack = await this.pack;
4041
+ if (!pack) {
4041
4042
  throw new InternalError(
4042
- 'Tried to read from a GitPackIndex with no packfile loaded into memory'
4043
+ 'Could not read packfile data. The packfile may be missing, corrupted, or too large to read into memory.'
4043
4044
  )
4044
4045
  }
4045
- const raw = (await this.pack).slice(start);
4046
+ const raw = pack.slice(start);
4046
4047
  const reader = new BufferCursor(raw);
4047
4048
  const byte = reader.readUInt8();
4048
4049
  // Object type is encoded in bits 654
@@ -4154,12 +4155,18 @@ async function readObjectPacked({
4154
4155
  if (p.error) throw new InternalError(p.error)
4155
4156
  // If the packfile DOES have the oid we're looking for...
4156
4157
  if (p.offsets.has(oid)) {
4157
- // Get the resolved git object from the packfile
4158
+ // Derive the .pack path from the .idx path
4159
+ const packFile = indexFile.replace(/idx$/, 'pack');
4158
4160
  if (!p.pack) {
4159
- const packFile = indexFile.replace(/idx$/, 'pack');
4160
4161
  p.pack = fs.read(packFile);
4161
4162
  }
4162
4163
  const pack = await p.pack;
4164
+ if (!pack) {
4165
+ p.pack = null;
4166
+ throw new InternalError(
4167
+ `Could not read packfile at ${packFile}. The file may be missing, corrupted, or too large to read into memory.`
4168
+ )
4169
+ }
4163
4170
 
4164
4171
  // === Packfile Integrity Verification ===
4165
4172
  // Performance optimization: use _checksumVerified flag to verify only once per packfile
package/managers/index.js CHANGED
@@ -4031,12 +4031,13 @@ class GitPackIndex {
4031
4031
  0b1100000: 'ofs_delta',
4032
4032
  0b1110000: 'ref_delta',
4033
4033
  };
4034
- if (!this.pack) {
4034
+ const pack = await this.pack;
4035
+ if (!pack) {
4035
4036
  throw new InternalError(
4036
- 'Tried to read from a GitPackIndex with no packfile loaded into memory'
4037
+ 'Could not read packfile data. The packfile may be missing, corrupted, or too large to read into memory.'
4037
4038
  )
4038
4039
  }
4039
- const raw = (await this.pack).slice(start);
4040
+ const raw = pack.slice(start);
4040
4041
  const reader = new BufferCursor(raw);
4041
4042
  const byte = reader.readUInt8();
4042
4043
  // Object type is encoded in bits 654
@@ -4148,12 +4149,18 @@ async function readObjectPacked({
4148
4149
  if (p.error) throw new InternalError(p.error)
4149
4150
  // If the packfile DOES have the oid we're looking for...
4150
4151
  if (p.offsets.has(oid)) {
4151
- // Get the resolved git object from the packfile
4152
+ // Derive the .pack path from the .idx path
4153
+ const packFile = indexFile.replace(/idx$/, 'pack');
4152
4154
  if (!p.pack) {
4153
- const packFile = indexFile.replace(/idx$/, 'pack');
4154
4155
  p.pack = fs.read(packFile);
4155
4156
  }
4156
4157
  const pack = await p.pack;
4158
+ if (!pack) {
4159
+ p.pack = null;
4160
+ throw new InternalError(
4161
+ `Could not read packfile at ${packFile}. The file may be missing, corrupted, or too large to read into memory.`
4162
+ )
4163
+ }
4157
4164
 
4158
4165
  // === Packfile Integrity Verification ===
4159
4166
  // Performance optimization: use _checksumVerified flag to verify only once per packfile