mirror of
https://github.com/garraflavatra/go-fmp.git
synced 2025-06-27 12:05:11 +00:00
Add error handling for processChunks
This commit is contained in:
@ -52,8 +52,12 @@ func OpenFile(path string) (*FmpFile, error) {
|
||||
}
|
||||
|
||||
ctx.Sectors = append(ctx.Sectors, sector)
|
||||
|
||||
if sector.ID != 0 {
|
||||
sector.processChunks(ctx.Dictionary, ¤tPath)
|
||||
err = sector.processChunks(ctx.Dictionary, ¤tPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ctx.Chunks = append(ctx.Chunks, sector.Chunks...)
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ func (sect *FmpSector) readChunks() error {
|
||||
panic("chunks already read")
|
||||
}
|
||||
for {
|
||||
pos := (sect.ID+2)*sectorSize - uint64(len(sect.Payload))
|
||||
pos := sect.ID*sectorSize - uint64(len(sect.Payload))
|
||||
|
||||
chunk, err := sect.readChunk(sect.Payload)
|
||||
if chunk == nil {
|
||||
@ -46,8 +46,12 @@ func (sect *FmpSector) readChunks() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sect *FmpSector) processChunks(dict *FmpDict, currentPath *[]uint64) {
|
||||
sect.readChunks()
|
||||
func (sect *FmpSector) processChunks(dict *FmpDict, currentPath *[]uint64) error {
|
||||
err := sect.readChunks()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, chunk := range sect.Chunks {
|
||||
switch chunk.Type {
|
||||
case FMP_CHUNK_PATH_PUSH:
|
||||
@ -92,6 +96,7 @@ func (sect *FmpSector) processChunks(dict *FmpDict, currentPath *[]uint64) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sect *FmpSector) readChunk(payload []byte) (*FmpChunk, error) {
|
||||
|
Reference in New Issue
Block a user