fix: Returned a file not found error on unity file reads
This commit is contained in:
parent
5ad8bd2407
commit
a2468a832f
@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
|
||||
"git.nicholasnovak.io/nnovak/spatial-db/world"
|
||||
@ -115,7 +116,10 @@ func (u *UnityFile) ReadMetadataFile(fileName string) error {
|
||||
}
|
||||
|
||||
func (u UnityFile) ReadChunk(pos world.ChunkPos) (world.ChunkData, error) {
|
||||
m := u.metadata[pos]
|
||||
m, contains := u.metadata[pos]
|
||||
if !contains {
|
||||
return world.ChunkData{}, fs.ErrNotExist
|
||||
}
|
||||
|
||||
u.fd.Seek(int64(m.StartOffset), io.SeekStart)
|
||||
|
||||
|
@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"git.nicholasnovak.io/nnovak/spatial-db/storage"
|
||||
@ -19,7 +18,7 @@ func readBlockTemplate(
|
||||
for i := 0; i < b.N; i++ {
|
||||
pos := world.RandomBlockPosWithRange(float64(pointSpread))
|
||||
if _, err := storageServer.ReadBlockAt(pos); err != nil {
|
||||
if errors.Is(err, storage.ChunkNotFoundError) || errors.Is(err, io.EOF) {
|
||||
if errors.Is(err, storage.ChunkNotFoundError) {
|
||||
continue
|
||||
} else {
|
||||
b.Error(err)
|
||||
|
Loading…
Reference in New Issue
Block a user