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"
|
|
|
|
|
2023-03-07 14:38:08 +00:00
|
|
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
|
|
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user"
|
2022-05-20 15:02:00 +00:00
|
|
|
)
|
|
|
|
|
2022-08-08 22:35:26 +00:00
|
|
|
const (
|
|
|
|
UnversionedObjectVersionID = "null"
|
|
|
|
)
|
|
|
|
|
2022-05-20 15:02:00 +00:00
|
|
|
// NodeVersion represent node from tree service.
|
|
|
|
type NodeVersion struct {
|
|
|
|
BaseNodeVersion
|
|
|
|
DeleteMarker *DeleteMarkerInfo
|
|
|
|
IsUnversioned bool
|
2023-06-27 12:49:20 +00:00
|
|
|
IsCombined bool
|
2022-05-20 15:02:00 +00:00
|
|
|
}
|
|
|
|
|
2022-08-09 12:10:04 +00:00
|
|
|
func (v NodeVersion) IsDeleteMarker() bool {
|
|
|
|
return v.DeleteMarker != nil
|
|
|
|
}
|
|
|
|
|
2022-05-20 15:02:00 +00:00
|
|
|
// DeleteMarkerInfo is used to save object info if node in the tree service is delete marker.
|
2022-12-20 08:38:58 +00:00
|
|
|
// We need this information because the "delete marker" object is no longer stored in FrostFS.
|
2022-05-20 15:02:00 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-08-08 22:35:26 +00:00
|
|
|
func (e ExtendedObjectInfo) Version() string {
|
|
|
|
if e.NodeVersion.IsUnversioned {
|
|
|
|
return UnversionedObjectVersionID
|
|
|
|
}
|
|
|
|
|
|
|
|
return e.ObjectInfo.ID.EncodeToString()
|
|
|
|
}
|
|
|
|
|
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
|
2022-09-07 08:46:08 +00:00
|
|
|
ParenID uint64
|
2022-05-20 15:02:00 +00:00
|
|
|
OID oid.ID
|
|
|
|
Timestamp uint64
|
2023-06-01 13:45:28 +00:00
|
|
|
Size uint64
|
2022-07-18 14:51:34 +00:00
|
|
|
ETag string
|
2023-10-02 08:52:07 +00:00
|
|
|
MD5 string
|
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.
|
2023-04-24 23:49:12 +00:00
|
|
|
ID uint64
|
|
|
|
Key string
|
|
|
|
UploadID string
|
|
|
|
Owner user.ID
|
|
|
|
Created time.Time
|
|
|
|
Meta map[string]string
|
|
|
|
CopiesNumbers []uint32
|
2023-12-04 06:42:25 +00:00
|
|
|
Finished bool
|
2022-05-23 14:34:13 +00:00
|
|
|
}
|
2022-05-24 11:30:37 +00:00
|
|
|
|
|
|
|
// PartInfo is upload information about part.
|
|
|
|
type PartInfo struct {
|
2023-06-27 12:49:20 +00:00
|
|
|
Key string `json:"key"`
|
|
|
|
UploadID string `json:"uploadId"`
|
|
|
|
Number int `json:"number"`
|
|
|
|
OID oid.ID `json:"oid"`
|
|
|
|
Size uint64 `json:"size"`
|
|
|
|
ETag string `json:"etag"`
|
2023-10-02 08:52:07 +00:00
|
|
|
MD5 string `json:"md5"`
|
2023-06-27 12:49:20 +00:00
|
|
|
Created time.Time `json:"created"`
|
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 {
|
2023-10-27 15:15:33 +00:00
|
|
|
// ETag value contains SHA256 checksum which is used while getting object parts attributes.
|
2023-06-01 13:45:28 +00:00
|
|
|
return strconv.Itoa(p.Number) + "-" + strconv.FormatUint(p.Size, 10) + "-" + p.ETag
|
2022-06-02 15:26:26 +00:00
|
|
|
}
|
|
|
|
|
2023-10-27 15:15:33 +00:00
|
|
|
func (p *PartInfo) GetETag(md5Enabled bool) string {
|
|
|
|
if md5Enabled && len(p.MD5) > 0 {
|
|
|
|
return p.MD5
|
|
|
|
}
|
|
|
|
return 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
|
|
|
}
|