2022-05-20 15:02:00 +00:00
|
|
|
package data
|
|
|
|
|
|
|
|
import (
|
2022-06-02 15:26:26 +00:00
|
|
|
"strconv"
|
2022-05-20 15:02:00 +00:00
|
|
|
"time"
|
|
|
|
|
2022-05-24 06:58:33 +00:00
|
|
|
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
2022-05-20 15:02:00 +00:00
|
|
|
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
|
|
|
"github.com/nspcc-dev/neofs-sdk-go/user"
|
|
|
|
)
|
|
|
|
|
|
|
|
// NodeVersion represent node from tree service.
|
|
|
|
type NodeVersion struct {
|
|
|
|
BaseNodeVersion
|
|
|
|
DeleteMarker *DeleteMarkerInfo
|
|
|
|
IsUnversioned bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteMarkerInfo is used to save object info if node in the tree service is delete marker.
|
|
|
|
// We need this information because the "delete marker" object is no longer stored in NeoFS.
|
|
|
|
type DeleteMarkerInfo struct {
|
2022-06-10 11:57:41 +00:00
|
|
|
Created time.Time
|
|
|
|
Owner user.ID
|
2022-05-20 15:02:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ExtendedObjectInfo contains additional node info to be able to sort versions by timestamp.
|
|
|
|
type ExtendedObjectInfo struct {
|
|
|
|
ObjectInfo *ObjectInfo
|
|
|
|
NodeVersion *NodeVersion
|
2022-05-31 15:03:58 +00:00
|
|
|
IsLatest bool
|
2022-05-20 15:02:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// BaseNodeVersion is minimal node info from tree service.
|
|
|
|
// Basically used for "system" object.
|
|
|
|
type BaseNodeVersion struct {
|
|
|
|
ID uint64
|
|
|
|
OID oid.ID
|
|
|
|
Timestamp uint64
|
2022-06-10 11:57:41 +00:00
|
|
|
FilePath string
|
2022-05-20 15:02:00 +00:00
|
|
|
}
|
2022-05-24 06:58:33 +00:00
|
|
|
|
|
|
|
type ObjectTaggingInfo struct {
|
2022-06-27 09:08:26 +00:00
|
|
|
CnrID cid.ID
|
2022-05-24 06:58:33 +00:00
|
|
|
ObjName string
|
|
|
|
VersionID string
|
|
|
|
}
|
2022-05-23 14:34:13 +00:00
|
|
|
|
|
|
|
// MultipartInfo is multipart upload information.
|
|
|
|
type MultipartInfo struct {
|
2022-05-24 11:30:37 +00:00
|
|
|
// ID is node id in tree service.
|
|
|
|
// It's ignored when creating a new multipart upload.
|
|
|
|
ID uint64
|
2022-05-24 08:41:10 +00:00
|
|
|
Key string
|
2022-05-23 14:34:13 +00:00
|
|
|
UploadID string
|
|
|
|
Owner user.ID
|
|
|
|
Created time.Time
|
|
|
|
Meta map[string]string
|
|
|
|
}
|
2022-05-24 11:30:37 +00:00
|
|
|
|
|
|
|
// PartInfo is upload information about part.
|
|
|
|
type PartInfo struct {
|
|
|
|
Key string
|
|
|
|
UploadID string
|
|
|
|
Number int
|
|
|
|
OID oid.ID
|
2022-05-31 12:38:06 +00:00
|
|
|
Size int64
|
|
|
|
ETag string
|
|
|
|
Created time.Time
|
2022-05-24 11:30:37 +00:00
|
|
|
}
|
2022-05-26 13:11:14 +00:00
|
|
|
|
2022-06-02 15:26:26 +00:00
|
|
|
// ToHeaderString form short part representation to use in S3-Completed-Parts header.
|
|
|
|
func (p *PartInfo) ToHeaderString() string {
|
|
|
|
return strconv.Itoa(p.Number) + "-" + strconv.FormatInt(p.Size, 10) + "-" + p.ETag
|
|
|
|
}
|
|
|
|
|
2022-05-26 13:11:14 +00:00
|
|
|
// LockInfo is lock information to create appropriate tree node.
|
|
|
|
type LockInfo struct {
|
2022-06-27 09:33:36 +00:00
|
|
|
id uint64
|
|
|
|
|
|
|
|
legalHoldOID oid.ID
|
|
|
|
setLegalHold bool
|
|
|
|
|
|
|
|
retentionOID oid.ID
|
|
|
|
setRetention bool
|
|
|
|
untilDate string
|
|
|
|
isCompliance bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewLockInfo(id uint64) *LockInfo {
|
|
|
|
return &LockInfo{id: id}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l LockInfo) ID() uint64 {
|
|
|
|
return l.id
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *LockInfo) SetLegalHold(objID oid.ID) {
|
|
|
|
l.legalHoldOID = objID
|
|
|
|
l.setLegalHold = true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *LockInfo) ResetLegalHold() {
|
|
|
|
l.setLegalHold = false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l LockInfo) LegalHold() oid.ID {
|
|
|
|
return l.legalHoldOID
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l LockInfo) IsLegalHoldSet() bool {
|
|
|
|
return l.setLegalHold
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *LockInfo) SetRetention(objID oid.ID, until string, isCompliance bool) {
|
|
|
|
l.retentionOID = objID
|
|
|
|
l.setRetention = true
|
|
|
|
l.untilDate = until
|
|
|
|
l.isCompliance = isCompliance
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l LockInfo) IsRetentionSet() bool {
|
|
|
|
return l.setRetention
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l LockInfo) Retention() oid.ID {
|
|
|
|
return l.retentionOID
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l LockInfo) UntilDate() string {
|
|
|
|
return l.untilDate
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l LockInfo) IsCompliance() bool {
|
|
|
|
return l.isCompliance
|
2022-05-26 13:11:14 +00:00
|
|
|
}
|