mirror of
https://github.com/get-drexa/drive.git
synced 2025-11-30 21:41:39 +00:00
fix: vfs node primary id not generated properly
This commit is contained in:
@@ -28,18 +28,22 @@ type Node struct {
|
||||
ID uuid.UUID `bun:",pk,type:uuid"`
|
||||
PublicID string `bun:"public_id,notnull"`
|
||||
AccountID uuid.UUID `bun:"account_id,notnull,type:uuid"`
|
||||
ParentID uuid.UUID `bun:"parent_id"`
|
||||
ParentID uuid.UUID `bun:"parent_id,nullzero"`
|
||||
Kind NodeKind `bun:"kind,notnull"`
|
||||
Status NodeStatus `bun:"status,notnull"`
|
||||
Name string `bun:"name,notnull"`
|
||||
|
||||
BlobKey blob.Key `bun:"blob_key"`
|
||||
BlobKey blob.Key `bun:"blob_key,nullzero"`
|
||||
Size int64 `bun:"size"`
|
||||
MimeType string `bun:"mime_type"`
|
||||
MimeType string `bun:"mime_type,nullzero"`
|
||||
|
||||
CreatedAt time.Time `bun:"created_at,notnull,nullzero"`
|
||||
UpdatedAt time.Time `bun:"updated_at,notnull,nullzero"`
|
||||
DeletedAt time.Time `bun:"deleted_at"`
|
||||
DeletedAt time.Time `bun:"deleted_at,nullzero"`
|
||||
}
|
||||
|
||||
func newNodeID() (uuid.UUID, error) {
|
||||
return uuid.NewV7()
|
||||
}
|
||||
|
||||
// IsAccessible returns true if the node can be accessed.
|
||||
|
||||
@@ -125,7 +125,13 @@ func (vfs *VirtualFS) CreateFile(ctx context.Context, db bun.IDB, accountID uuid
|
||||
return nil, err
|
||||
}
|
||||
|
||||
id, err := newNodeID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
node := Node{
|
||||
ID: id,
|
||||
PublicID: pid,
|
||||
AccountID: accountID,
|
||||
ParentID: opts.ParentID,
|
||||
@@ -239,7 +245,13 @@ func (vfs *VirtualFS) CreateDirectory(ctx context.Context, db bun.IDB, accountID
|
||||
return nil, err
|
||||
}
|
||||
|
||||
id, err := newNodeID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
node := Node{
|
||||
ID: id,
|
||||
PublicID: pid,
|
||||
AccountID: accountID,
|
||||
ParentID: parentID,
|
||||
|
||||
Reference in New Issue
Block a user