oficina / docs Public

Clone
git clone https://amadan.net/oficina/docs

Plain git — no account needed to clone.

Download

Download this file

1package docs
2
3import "fmt"
4
5func (c *contentCipher) sealUpdate(guid string, row *DocUpdate) error {
6 sealed, err := c.seal(contentUpdateKind, guid, row.Seq, 0, row.UpdateBin)
7 if err != nil {
8 return fmt.Errorf("docs: seal update %d: %w", row.ID, err)
9 }
10 row.UpdateBin = sealed
11 row.ContentEncoding = contentEncoding
12 return nil
13}
14
15func (c *contentCipher) openUpdate(guid string, row *DocUpdate) error {
16 if row.ContentEncoding != contentEncoding {
17 return errContentEncoding
18 }
19 plain, err := c.open(contentUpdateKind, guid, row.Seq, 0, row.UpdateBin)
20 if err != nil {
21 return fmt.Errorf("docs: open update %d: %w", row.ID, err)
22 }
23 row.UpdateBin = plain
24 return nil
25}
26
27func (c *contentCipher) sealSnapshot(guid string, row *DocSnapshot) error {
28 sealed, err := c.seal(contentSnapshotKind, guid, row.Seq, row.ABIVersion, row.State)
29 if err != nil {
30 return fmt.Errorf("docs: seal snapshot %d: %w", row.ID, err)
31 }
32 row.State = sealed
33 row.ContentEncoding = contentEncoding
34 return nil
35}
36
37func (c *contentCipher) openSnapshot(guid string, row *DocSnapshot) error {
38 if row.ContentEncoding != contentEncoding {
39 return errContentEncoding
40 }
41 plain, err := c.open(contentSnapshotKind, guid, row.Seq, row.ABIVersion, row.State)
42 if err != nil {
43 return fmt.Errorf("docs: open snapshot %d: %w", row.ID, err)
44 }
45 row.State = plain
46 return nil
47}
48