Use SaveBlock api

This commit is contained in:
Peter Stuifzand 2021-08-18 21:15:41 +02:00
parent 764c67a707
commit 9184de2d1a

11
file.go
View File

@ -467,19 +467,10 @@ func (fp* FilePages) saveBlocksFromPage(dirname string, page Page) error {
}
for id, block := range blocks {
log.Printf("Writing to %q\n", id)
f, err := os.OpenFile(filepath.Join(dirname, BlocksDirectory, id), os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
if err != nil {
log.Println(err)
continue
}
enc := json.NewEncoder(f)
enc.SetIndent("", " ")
err = enc.Encode(&block)
err := fp.blockRepo.SaveBlock(id, block)
if err != nil {
log.Println(err)
}
f.Close()
}
return err