@@ -125,21 +125,18 @@ type ProtoShare struct {
125125
126126// Share is a regular share between users or groups. The unique index ensures that there
127127// can only be one share per (inode, instance, permissions, recipient) tuple, unless the share is deleted:
128- // for that, we redeclare the corresponding fields for GORM to define the unique index.
128+ // for that, we redeclare `DeletedAt`, `Inode`, and `Instance` for GORM to define the unique index.
129129type Share struct {
130130 ProtoShare
131131 DeletedAt gorm.DeletedAt `gorm:"uniqueIndex:u_share"`
132132 Inode string `gorm:"size:32;uniqueIndex:u_share"`
133133 Instance string `gorm:"size:32;uniqueIndex:u_share"`
134- Permissions uint8 `gorm:"uniqueIndex:u_share"`
135134 ShareWith string `gorm:"size:255;uniqueIndex:u_share"` // 255 because this can be an external account, which has a long representation
136135 SharedWithIsGroup bool
137136 Description string `gorm:"size:1024"`
138137}
139138
140- // PublicLink is a public link share.
141- // TODO(lopresti) We could enforce a unique index on (UIDInitiator, Inode, Permissions, DeleteAt) but for now web allows
142- // the creation of multiple links (with or without different names), so we only enforce a unique constraint on the token.
139+ // PublicLink is a public link share. We only enforce a unique constraint on the token.
143140type PublicLink struct {
144141 ProtoShare
145142 Token string `gorm:"uniqueIndex:u_link_token;size:32"` // Current tokens are only 16 chars long, but old tokens used to be 32 characters
@@ -162,14 +159,14 @@ type ShareState struct {
162159}
163160
164161// OcmShare represents an OCM share for a remote user. The unique index ensures that there
165- // can only be one share per (storageId, fileId , shareWith, owner) tuple, unless the share is deleted:
166- // for that, we redeclare the DeletedAt as in Share. In addition, tokens must be unique.
162+ // can only be one share per (inode, instance , shareWith, owner) tuple, unless the share is deleted:
163+ // for that, we redeclare ` DeletedAt`, `Inode`, and `Instance` as in Share. In addition, tokens must be unique.
167164type OcmShare struct {
168165 BaseModel
169166 DeletedAt gorm.DeletedAt `gorm:"uniqueIndex:u_ocmshare"`
167+ Inode string `gorm:"size:64;not null;uniqueIndex:u_ocmshare"`
168+ Instance string `gorm:"size:64;not null;uniqueIndex:u_ocmshare"`
170169 Token string `gorm:"size:255;not null;uniqueIndex:u_ocmshare_token"`
171- StorageId string `gorm:"size:64;not null;uniqueIndex:u_ocmshare"`
172- FileId string `gorm:"size:64;not null;uniqueIndex:u_ocmshare"`
173170 Name string `gorm:"type:text;not null"`
174171 ShareWith string `gorm:"size:255;not null;uniqueIndex:u_ocmshare"`
175172 Owner string `gorm:"size:255;not null;uniqueIndex:u_ocmshare"`
0 commit comments