working commit
This commit is contained in:
@@ -3,7 +3,7 @@ package maindb
|
||||
import (
|
||||
"context"
|
||||
|
||||
"mstore/app/descr"
|
||||
"mstore/pkg/descr"
|
||||
)
|
||||
|
||||
func (db *Database) InsertAccount(ctx context.Context, account *descr.Account) error {
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ package maindb
|
||||
import (
|
||||
"context"
|
||||
|
||||
"mstore/app/descr"
|
||||
"mstore/pkg/descr"
|
||||
)
|
||||
|
||||
func (db *Database) InsertBlob(ctx context.Context, layer *descr.Blob) error {
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ package maindb
|
||||
import (
|
||||
"context"
|
||||
|
||||
"mstore/app/descr"
|
||||
"mstore/pkg/descr"
|
||||
)
|
||||
|
||||
func (db *Database) InsertFile(ctx context.Context, file *descr.File) error {
|
||||
|
||||
@@ -14,9 +14,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"mstore/app/descr"
|
||||
"mstore/pkg/auxtool"
|
||||
"mstore/pkg/auxuuid"
|
||||
"mstore/pkg/descr"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ package maindb
|
||||
import (
|
||||
"context"
|
||||
|
||||
"mstore/app/descr"
|
||||
"mstore/pkg/descr"
|
||||
)
|
||||
|
||||
func (db *Database) InsertGrant(ctx context.Context, grant *descr.Grant) error {
|
||||
|
||||
@@ -14,9 +14,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"mstore/app/descr"
|
||||
"mstore/pkg/auxtool"
|
||||
"mstore/pkg/auxuuid"
|
||||
"mstore/pkg/descr"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
+35
-34
@@ -13,10 +13,11 @@ package maindb
|
||||
import (
|
||||
"context"
|
||||
|
||||
"mstore/app/descr"
|
||||
"mstore/pkg/auxpwd"
|
||||
"mstore/pkg/auxtool"
|
||||
"mstore/pkg/auxuuid"
|
||||
"mstore/pkg/descr"
|
||||
"mstore/pkg/terms"
|
||||
)
|
||||
|
||||
func (db *Database) WriteAnonymous(ctx context.Context) error {
|
||||
@@ -26,14 +27,14 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
|
||||
password := auxtool.RandomString(64)
|
||||
passhash := auxpwd.MakeSHA256Hash([]byte(password))
|
||||
accountDescr := &descr.Account{
|
||||
ID: descr.AnonymousID,
|
||||
Username: descr.AnonimousUsername,
|
||||
ID: terms.AnonymousID,
|
||||
Username: terms.AnonimousUsername,
|
||||
Passhash: passhash,
|
||||
Disabled: false,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: descr.ServerID,
|
||||
UpdatedBy: descr.ServerID,
|
||||
CreatedBy: terms.ServerID,
|
||||
UpdatedBy: terms.ServerID,
|
||||
}
|
||||
err = db.InsertAccount(ctx, accountDescr)
|
||||
if err != nil {
|
||||
@@ -42,12 +43,12 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
|
||||
grantDescr := &descr.Grant{
|
||||
ID: auxuuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: descr.RightReadFiles,
|
||||
Right: terms.RightReadFiles,
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: descr.ServerID,
|
||||
UpdatedBy: descr.ServerID,
|
||||
CreatedBy: terms.ServerID,
|
||||
UpdatedBy: terms.ServerID,
|
||||
}
|
||||
err = db.InsertGrant(ctx, grantDescr)
|
||||
if err != nil {
|
||||
@@ -56,12 +57,12 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
|
||||
grantDescr = &descr.Grant{
|
||||
ID: auxuuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: descr.RightReadImages,
|
||||
Right: terms.RightReadImages,
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: descr.ServerID,
|
||||
UpdatedBy: descr.ServerID,
|
||||
CreatedBy: terms.ServerID,
|
||||
UpdatedBy: terms.ServerID,
|
||||
}
|
||||
err = db.InsertGrant(ctx, grantDescr)
|
||||
if err != nil {
|
||||
@@ -75,16 +76,16 @@ func (db *Database) WriteAnonymous(ctx context.Context) error {
|
||||
func (db *Database) WriteInituser(ctx context.Context) error {
|
||||
var err error
|
||||
now := auxtool.TimeNow()
|
||||
passhash := auxpwd.MakeSHA256Hash([]byte(descr.InitUsername))
|
||||
passhash := auxpwd.MakeSHA256Hash([]byte(terms.InitUsername))
|
||||
accountDescr := &descr.Account{
|
||||
ID: descr.InitID,
|
||||
Username: descr.InitUsername,
|
||||
ID: terms.InitID,
|
||||
Username: terms.InitUsername,
|
||||
Passhash: passhash,
|
||||
Disabled: false,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: descr.ServerID,
|
||||
UpdatedBy: descr.ServerID,
|
||||
CreatedBy: terms.ServerID,
|
||||
UpdatedBy: terms.ServerID,
|
||||
}
|
||||
err = db.InsertAccount(ctx, accountDescr)
|
||||
if err != nil {
|
||||
@@ -94,12 +95,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
||||
grantDescr := &descr.Grant{
|
||||
ID: auxuuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: descr.RightReadFiles,
|
||||
Right: terms.RightReadFiles,
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: descr.ServerID,
|
||||
UpdatedBy: descr.ServerID,
|
||||
CreatedBy: terms.ServerID,
|
||||
UpdatedBy: terms.ServerID,
|
||||
}
|
||||
err = db.InsertGrant(ctx, grantDescr)
|
||||
if err != nil {
|
||||
@@ -108,12 +109,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
||||
grantDescr = &descr.Grant{
|
||||
ID: auxuuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: descr.RightWriteFiles,
|
||||
Right: terms.RightWriteFiles,
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: descr.ServerID,
|
||||
UpdatedBy: descr.ServerID,
|
||||
CreatedBy: terms.ServerID,
|
||||
UpdatedBy: terms.ServerID,
|
||||
}
|
||||
err = db.InsertGrant(ctx, grantDescr)
|
||||
if err != nil {
|
||||
@@ -123,12 +124,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
||||
grantDescr = &descr.Grant{
|
||||
ID: auxuuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: descr.RightReadAccounts,
|
||||
Right: terms.RightReadAccounts,
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: descr.ServerID,
|
||||
UpdatedBy: descr.ServerID,
|
||||
CreatedBy: terms.ServerID,
|
||||
UpdatedBy: terms.ServerID,
|
||||
}
|
||||
err = db.InsertGrant(ctx, grantDescr)
|
||||
if err != nil {
|
||||
@@ -137,12 +138,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
||||
grantDescr = &descr.Grant{
|
||||
ID: auxuuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: descr.RightWriteAccounts,
|
||||
Right: terms.RightWriteAccounts,
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: descr.ServerID,
|
||||
UpdatedBy: descr.ServerID,
|
||||
CreatedBy: terms.ServerID,
|
||||
UpdatedBy: terms.ServerID,
|
||||
}
|
||||
err = db.InsertGrant(ctx, grantDescr)
|
||||
if err != nil {
|
||||
@@ -152,12 +153,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
||||
grantDescr = &descr.Grant{
|
||||
ID: auxuuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: descr.RightReadImages,
|
||||
Right: terms.RightReadImages,
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: descr.ServerID,
|
||||
UpdatedBy: descr.ServerID,
|
||||
CreatedBy: terms.ServerID,
|
||||
UpdatedBy: terms.ServerID,
|
||||
}
|
||||
err = db.InsertGrant(ctx, grantDescr)
|
||||
if err != nil {
|
||||
@@ -166,12 +167,12 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
||||
grantDescr = &descr.Grant{
|
||||
ID: auxuuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: descr.RightWriteImages,
|
||||
Right: terms.RightWriteImages,
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
CreatedBy: descr.ServerID,
|
||||
UpdatedBy: descr.ServerID,
|
||||
CreatedBy: terms.ServerID,
|
||||
UpdatedBy: terms.ServerID,
|
||||
}
|
||||
err = db.InsertGrant(ctx, grantDescr)
|
||||
if err != nil {
|
||||
|
||||
@@ -12,7 +12,7 @@ package maindb
|
||||
import (
|
||||
"context"
|
||||
|
||||
"mstore/app/descr"
|
||||
"mstore/pkg/descr"
|
||||
)
|
||||
|
||||
func (db *Database) InsertManifest(ctx context.Context, manifest *descr.Manifest) error {
|
||||
|
||||
Reference in New Issue
Block a user