Use SaveBlock api
This commit is contained in:
parent
764c67a707
commit
9184de2d1a
11
file.go
11
file.go
|
@ -467,19 +467,10 @@ func (fp* FilePages) saveBlocksFromPage(dirname string, page Page) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for id, block := range blocks {
|
for id, block := range blocks {
|
||||||
log.Printf("Writing to %q\n", id)
|
err := fp.blockRepo.SaveBlock(id, block)
|
||||||
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)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
f.Close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue
Block a user