From 9184de2d1a02cde9d53bec98bed547eb66aea62d Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Wed, 18 Aug 2021 21:15:41 +0200 Subject: [PATCH] Use SaveBlock api --- file.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/file.go b/file.go index 496c271..6ffd4b0 100644 --- a/file.go +++ b/file.go @@ -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