-
Notifications
You must be signed in to change notification settings - Fork 337
/
info.go
41 lines (33 loc) · 1.06 KB
/
info.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package content
import (
"time"
"github.com/kopia/kopia/repo/blob"
)
// ID is an identifier of content in content-addressable storage.
type ID string
// Prefix returns a one-character prefix of a content ID or an empty string.
func (i ID) Prefix() ID {
if i.HasPrefix() {
return i[0:1]
}
return ""
}
// HasPrefix determines if the given ID has a non-empty prefix.
func (i ID) HasPrefix() bool {
return len(i)%2 == 1
}
// Info is an information about a single piece of content managed by Manager.
type Info struct {
ID ID `json:"contentID"`
Length uint32 `json:"length"`
TimestampSeconds int64 `json:"time"`
PackBlobID blob.ID `json:"packFile,omitempty"`
PackOffset uint32 `json:"packOffset,omitempty"`
Deleted bool `json:"deleted"`
Payload []byte `json:"payload"` // set for payloads stored inline
FormatVersion byte `json:"formatVersion"`
}
// Timestamp returns the time when a content was created or deleted.
func (i *Info) Timestamp() time.Time {
return time.Unix(i.TimestampSeconds, 0)
}