MCPcopy Create free account
hub / github.com/couchbase/moss / checkHeader

Function checkHeader

store.go:417–450  ·  view source on GitHub ↗
(file File)

Source from the content-addressed store, hash-verified

415}
416
417func checkHeader(file File) error {
418 buf := make([]byte, StorePageSize)
419
420 n, err := file.ReadAt(buf, int64(0))
421 if err != nil {
422 return err
423 }
424 if n != len(buf) {
425 return fmt.Errorf("store: readHeader too short")
426 }
427
428 lines := strings.Split(string(buf), "\n")
429 if len(lines) < 2 {
430 return fmt.Errorf("store: readHeader not enough lines")
431 }
432 if lines[0] != "moss-data-store:" {
433 return fmt.Errorf("store: readHeader wrong file prefix")
434 }
435
436 hdr := Header{}
437 err = json.Unmarshal([]byte(lines[1]), &hdr)
438 if err != nil {
439 return err
440 }
441 if hdr.Version != StoreVersion {
442 return fmt.Errorf("store: readHeader wrong version")
443 }
444 if hdr.CreatedEndian != endian() {
445 return fmt.Errorf("store: readHeader endian of file was: %s, need: %s",
446 hdr.CreatedEndian, endian())
447 }
448
449 return nil
450}
451
452// --------------------------------------------------------
453

Callers 1

openStoreFunction · 0.85

Calls 1

endianFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…