Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
feat: add user-defined id to resource
Steven582cc6609cd8
diff --git a/api/v1/resource.go b/api/v1/resource.goindex 4297819c8..d6779aa84 100644--- a/api/v1/resource.go+++ b/api/v1/resource.go@@ -15,6 +15,7 @@ import ("time""github.com/labstack/echo/v4"+ "github.com/lithammer/shortuuid/v4""github.com/pkg/errors""go.uber.org/zap"@@ -139,6 +140,7 @@ func (s *APIV1Service) CreateResource(c echo.Context) error {}create := &store.Resource{+ ResourceName: shortuuid.New(),CreatorID: userID,Filename: request.Filename,ExternalLink: request.ExternalLink,@@ -215,10 +217,11 @@ func (s *APIV1Service) UploadResource(c echo.Context) error {defer sourceFile.Close()create := &store.Resource{- CreatorID: userID,- Filename: file.Filename,- Type: file.Header.Get("Content-Type"),- Size: file.Size,+ ResourceName: shortuuid.New(),+ CreatorID: userID,+ Filename: file.Filename,+ Type: file.Header.Get("Content-Type"),+ Size: file.Size,}err = SaveResourceBlob(ctx, s.Store, create, sourceFile)if err != nil {diff --git a/api/v2/resource_service.go b/api/v2/resource_service.goindex 36a352432..4b61fea59 100644--- a/api/v2/resource_service.go+++ b/api/v2/resource_service.go@@ -5,6 +5,7 @@ import ("net/url""time"+ "github.com/lithammer/shortuuid/v4""google.golang.org/grpc/codes""google.golang.org/grpc/status""google.golang.org/protobuf/types/known/timestamppb"@@ -30,6 +31,7 @@ func (s *APIV2Service) CreateResource(ctx context.Context, request *apiv2pb.Crea}create := &store.Resource{+ ResourceName: shortuuid.New(),CreatorID: user.ID,Filename: request.Filename,ExternalLink: request.ExternalLink,diff --git a/server/integration/telegram.go b/server/integration/telegram.goindex 5908e14f7..3e3650687 100644--- a/server/integration/telegram.go+++ b/server/integration/telegram.go@@ -86,11 +86,12 @@ func (t *TelegramHandler) MessageHandle(ctx context.Context, bot *telegram.Bot,for _, attachment := range attachments {// Fill the common field of createcreate := store.Resource{- CreatorID: creatorID,- Filename: filepath.Base(attachment.FileName),- Type: attachment.GetMimeType(),- Size: attachment.FileSize,- MemoID: &memoMessage.ID,+ ResourceName: shortuuid.New(),+ CreatorID: creatorID,+ Filename: filepath.Base(attachment.FileName),+ Type: attachment.GetMimeType(),+ Size: attachment.FileSize,+ MemoID: &memoMessage.ID,}err := apiv1.SaveResourceBlob(ctx, t.store, &create, bytes.NewReader(attachment.Data))diff --git a/store/db/mysql/migration/dev/LATEST__SCHEMA.sql b/store/db/mysql/migration/dev/LATEST__SCHEMA.sqlindex b5379a348..7db3fe57f 100644--- a/store/db/mysql/migration/dev/LATEST__SCHEMA.sql+++ b/store/db/mysql/migration/dev/LATEST__SCHEMA.sql@@ -64,6 +64,7 @@ CREATE TABLE `memo_relation` (-- resourceCREATE TABLE `resource` (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,+ `resource_name` VARCHAR(256) NOT NULL UNIQUE,`creator_id` INT NOT NULL,`created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,`updated_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,diff --git a/store/db/mysql/resource.go b/store/db/mysql/resource.goindex 302bf2501..76321e484 100644--- a/store/db/mysql/resource.go+++ b/store/db/mysql/resource.go@@ -6,15 +6,13 @@ import ("fmt""strings"- "github.com/pkg/errors"-"github.com/usememos/memos/store")func (d *DB) CreateResource(ctx context.Context, create *store.Resource) (*store.Resource, error) {- fields := []string{"`filename`", "`blob`", "`external_link`", "`type`", "`size`", "`creator_id`", "`internal_path`", "`memo_id`"}- placeholder := []string{"?", "?", "?", "?", "?", "?", "?", "?"}- args := []any{create.Filename, create.Blob, create.ExternalLink, create.Type, create.Size, create.CreatorID, create.InternalPath, create.MemoID}+ fields := []string{"`resource_name`", "`filename`", "`blob`", "`external_link`", "`type`", "`size`", "`creator_id`", "`internal_path`", "`memo_id`"}+ placeholder := []string{"?", "?", "?", "?", "?", "?", "?", "?", "?"}+ args := []any{create.ResourceName, create.Filename, create.Blob, create.ExternalLink, create.Type, create.Size, create.CreatorID, create.InternalPath, create.MemoID}stmt := "INSERT INTO `resource` (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(placeholder, ", ") + ")"result, err := d.db.ExecContext(ctx, stmt, args...)@@ -28,15 +26,7 @@ func (d *DB) CreateResource(ctx context.Context, create *store.Resource) (*store}id32 := int32(id)- list, err := d.ListResources(ctx, &store.FindResource{ID: &id32})- if err != nil {- return nil, err- }- if len(list) != 1 {- return nil, errors.Wrapf(nil, "unexpected resource count: %d", len(list))- }-- return list[0], nil+ return d.GetResource(ctx, &store.FindResource{ID: &id32})}func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*store.Resource, error) {@@ -45,6 +35,9 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*stif v := find.ID; v != nil {where, args = append(where, "`id` = ?"), append(args, *v)}+ if v := find.ResourceName; v != nil {+ where, args = append(where, "`resource_name` = ?"), append(args, *v)+ }if v := find.CreatorID; v != nil {where, args = append(where, "`creator_id` = ?"), append(args, *v)}@@ -58,7 +51,7 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*stwhere = append(where, "`memo_id` IS NOT NULL")}- fields := []string{"`id`", "`filename`", "`external_link`", "`type`", "`size`", "`creator_id`", "UNIX_TIMESTAMP(`created_ts`)", "UNIX_TIMESTAMP(`updated_ts`)", "`internal_path`", "`memo_id`"}+ fields := []string{"`id`", "`resource_name`", "`filename`", "`external_link`", "`type`", "`size`", "`creator_id`", "UNIX_TIMESTAMP(`created_ts`)", "UNIX_TIMESTAMP(`updated_ts`)", "`internal_path`", "`memo_id`"}if find.GetBlob {fields = append(fields, "`blob`")}@@ -83,6 +76,7 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*stvar memoID sql.NullInt32dests := []any{&resource.ID,+ &resource.ResourceName,&resource.Filename,&resource.ExternalLink,&resource.Type,@@ -112,9 +106,24 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*streturn list, nil}+func (d *DB) GetResource(ctx context.Context, find *store.FindResource) (*store.Resource, error) {+ list, err := d.ListResources(ctx, find)+ if err != nil {+ return nil, err+ }+ if len(list) == 0 {+ return nil, nil+ }++ return list[0], nil+}+func (d *DB) UpdateResource(ctx context.Context, update *store.UpdateResource) (*store.Resource, error) {set, args := []string{}, []any{}+ if v := update.ResourceName; v != nil {+ set, args = append(set, "`resource_name` = ?"), append(args, *v)+ }if v := update.UpdatedTs; v != nil {set, args = append(set, "`updated_ts` = FROM_UNIXTIME(?)"), append(args, *v)}@@ -137,15 +146,7 @@ func (d *DB) UpdateResource(ctx context.Context, update *store.UpdateResource) (return nil, err}- list, err := d.ListResources(ctx, &store.FindResource{ID: &update.ID})- if err != nil {- return nil, err- }- if len(list) != 1 {- return nil, errors.Wrapf(nil, "unexpected resource count: %d", len(list))- }-- return list[0], nil+ return d.GetResource(ctx, &store.FindResource{ID: &update.ID})}func (d *DB) DeleteResource(ctx context.Context, delete *store.DeleteResource) error {diff --git a/store/db/postgres/migration/dev/LATEST__SCHEMA.sql b/store/db/postgres/migration/dev/LATEST__SCHEMA.sqlindex b31e5f4eb..c0059ab3e 100644--- a/store/db/postgres/migration/dev/LATEST__SCHEMA.sql+++ b/store/db/postgres/migration/dev/LATEST__SCHEMA.sql@@ -64,6 +64,7 @@ CREATE TABLE memo_relation (-- resourceCREATE TABLE resource (id SERIAL PRIMARY KEY,+ resource_name TEXT NOT NULL UNIQUE,creator_id INTEGER NOT NULL,created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()),updated_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()),diff --git a/store/db/postgres/resource.go b/store/db/postgres/resource.goindex 235f56bf4..9409b14d6 100644--- a/store/db/postgres/resource.go+++ b/store/db/postgres/resource.go@@ -10,8 +10,8 @@ import ()func (d *DB) CreateResource(ctx context.Context, create *store.Resource) (*store.Resource, error) {- fields := []string{"filename", "blob", "external_link", "type", "size", "creator_id", "internal_path", "memo_id"}- args := []any{create.Filename, create.Blob, create.ExternalLink, create.Type, create.Size, create.CreatorID, create.InternalPath, create.MemoID}+ fields := []string{"resource_name", "filename", "blob", "external_link", "type", "size", "creator_id", "internal_path", "memo_id"}+ args := []any{create.ResourceName, create.Filename, create.Blob, create.ExternalLink, create.Type, create.Size, create.CreatorID, create.InternalPath, create.MemoID}stmt := "INSERT INTO resource (" + strings.Join(fields, ", ") + ") VALUES (" + placeholders(len(args)) + ") RETURNING id, created_ts, updated_ts"if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(&create.ID, &create.CreatedTs, &create.UpdatedTs); err != nil {@@ -26,6 +26,9 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*stif v := find.ID; v != nil {where, args = append(where, "id = "+placeholder(len(args)+1)), append(args, *v)}+ if v := find.ResourceName; v != nil {+ where, args = append(where, "resource_name = "+placeholder(len(args)+1)), append(args, *v)+ }if v := find.CreatorID; v != nil {where, args = append(where, "creator_id = "+placeholder(len(args)+1)), append(args, *v)}@@ -39,7 +42,7 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*stwhere = append(where, "memo_id IS NOT NULL")}- fields := []string{"id", "filename", "external_link", "type", "size", "creator_id", "created_ts", "updated_ts", "internal_path", "memo_id"}+ fields := []string{"id", "resource_name", "filename", "external_link", "type", "size", "creator_id", "created_ts", "updated_ts", "internal_path", "memo_id"}if find.GetBlob {fields = append(fields, "blob")}@@ -70,6 +73,7 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*stvar memoID sql.NullInt32dests := []any{&resource.ID,+ &resource.ResourceName,&resource.Filename,&resource.ExternalLink,&resource.Type,@@ -102,6 +106,9 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*stfunc (d *DB) UpdateResource(ctx context.Context, update *store.UpdateResource) (*store.Resource, error) {set, args := []string{}, []any{}+ if v := update.ResourceName; v != nil {+ set, args = append(set, "resource_name = "+placeholder(len(args)+1)), append(args, *v)+ }if v := update.UpdatedTs; v != nil {set, args = append(set, "updated_ts = "+placeholder(len(args)+1)), append(args, *v)}@@ -118,16 +125,13 @@ func (d *DB) UpdateResource(ctx context.Context, update *store.UpdateResource) (set, args = append(set, "blob = "+placeholder(len(args)+1)), append(args, v)}- fields := []string{"id", "filename", "external_link", "type", "size", "creator_id", "created_ts", "updated_ts", "internal_path"}- stmt := `- UPDATE resource- SET ` + strings.Join(set, ", ") + `- WHERE id = ` + placeholder(len(args)+1) + `- RETURNING ` + strings.Join(fields, ", ")+ fields := []string{"id", "resource_name", "filename", "external_link", "type", "size", "creator_id", "created_ts", "updated_ts", "internal_path"}+ stmt := `UPDATE resource SET ` + strings.Join(set, ", ") + ` WHERE id = ` + placeholder(len(args)+1) + ` RETURNING ` + strings.Join(fields, ", ")args = append(args, update.ID)resource := store.Resource{}dests := []any{&resource.ID,+ &resource.ResourceName,&resource.Filename,&resource.ExternalLink,&resource.Type,@@ -157,11 +161,7 @@ func (d *DB) DeleteResource(ctx context.Context, delete *store.DeleteResource) e}func vacuumResource(ctx context.Context, tx *sql.Tx) error {- stmt := `- DELETE FROM- resource- WHERE- creator_id NOT IN (SELECT id FROM "user")`+ stmt := `DELETE FROM resource WHERE creator_id NOT IN (SELECT id FROM "user")`_, err := tx.ExecContext(ctx, stmt)if err != nil {return errdiff --git a/store/db/sqlite/migration/dev/LATEST__SCHEMA.sql b/store/db/sqlite/migration/dev/LATEST__SCHEMA.sqlindex aa09178aa..5ddce5467 100644--- a/store/db/sqlite/migration/dev/LATEST__SCHEMA.sql+++ b/store/db/sqlite/migration/dev/LATEST__SCHEMA.sql@@ -1,19 +1,3 @@--- drop all tables first-DROP TABLE IF EXISTS migration_history;-DROP TABLE IF EXISTS system_setting;-DROP TABLE IF EXISTS user;-DROP TABLE IF EXISTS user_setting;-DROP TABLE IF EXISTS memo;-DROP TABLE IF EXISTS memo_organizer;-DROP TABLE IF EXISTS memo_relation;-DROP TABLE IF EXISTS resource;-DROP TABLE IF EXISTS tag;-DROP TABLE IF EXISTS activity;-DROP TABLE IF EXISTS storage;-DROP TABLE IF EXISTS idp;-DROP TABLE IF EXISTS inbox;-DROP TABLE IF EXISTS webhook;--- migration_historyCREATE TABLE migration_history (version TEXT NOT NULL PRIMARY KEY,@@ -87,6 +71,7 @@ CREATE TABLE memo_relation (-- resourceCREATE TABLE resource (id INTEGER PRIMARY KEY AUTOINCREMENT,+ resource_name TEXT NOT NULL UNIQUE,creator_id INTEGER NOT NULL,created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),updated_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),diff --git a/store/db/sqlite/resource.go b/store/db/sqlite/resource.goindex 2c7fde732..136098980 100644--- a/store/db/sqlite/resource.go+++ b/store/db/sqlite/resource.go@@ -10,9 +10,9 @@ import ()func (d *DB) CreateResource(ctx context.Context, create *store.Resource) (*store.Resource, error) {- fields := []string{"`filename`", "`blob`", "`external_link`", "`type`", "`size`", "`creator_id`", "`internal_path`", "`memo_id`"}- placeholder := []string{"?", "?", "?", "?", "?", "?", "?", "?"}- args := []any{create.Filename, create.Blob, create.ExternalLink, create.Type, create.Size, create.CreatorID, create.InternalPath, create.MemoID}+ fields := []string{"`resource_name`", "`filename`", "`blob`", "`external_link`", "`type`", "`size`", "`creator_id`", "`internal_path`", "`memo_id`"}+ placeholder := []string{"?", "?", "?", "?", "?", "?", "?", "?", "?"}+ args := []any{create.ResourceName, create.Filename, create.Blob, create.ExternalLink, create.Type, create.Size, create.CreatorID, create.InternalPath, create.MemoID}stmt := "INSERT INTO `resource` (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(placeholder, ", ") + ") RETURNING `id`, `created_ts`, `updated_ts`"if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(&create.ID, &create.CreatedTs, &create.UpdatedTs); err != nil {@@ -26,33 +26,30 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*stwhere, args := []string{"1 = 1"}, []any{}if v := find.ID; v != nil {- where, args = append(where, "id = ?"), append(args, *v)+ where, args = append(where, "`id` = ?"), append(args, *v)+ }+ if v := find.ResourceName; v != nil {+ where, args = append(where, "`resource_name` = ?"), append(args, *v)}if v := find.CreatorID; v != nil {- where, args = append(where, "creator_id = ?"), append(args, *v)+ where, args = append(where, "`creator_id` = ?"), append(args, *v)}if v := find.Filename; v != nil {- where, args = append(where, "filename = ?"), append(args, *v)+ where, args = append(where, "`filename` = ?"), append(args, *v)}if v := find.MemoID; v != nil {- where, args = append(where, "memo_id = ?"), append(args, *v)+ where, args = append(where, "`memo_id` = ?"), append(args, *v)}if find.HasRelatedMemo {- where = append(where, "memo_id IS NOT NULL")+ where = append(where, "`memo_id` IS NOT NULL")}- fields := []string{"id", "filename", "external_link", "type", "size", "creator_id", "created_ts", "updated_ts", "internal_path", "memo_id"}+ fields := []string{"`id`", "`resource_name`", "`filename`", "`external_link`", "`type`", "`size`", "`creator_id`", "`created_ts`", "`updated_ts`", "`internal_path`", "`memo_id`"}if find.GetBlob {- fields = append(fields, "blob")+ fields = append(fields, "`blob`")}- query := fmt.Sprintf(`- SELECT- %s- FROM resource- WHERE %s- ORDER BY updated_ts DESC, created_ts DESC- `, strings.Join(fields, ", "), strings.Join(where, " AND "))+ query := fmt.Sprintf("SELECT %s FROM `resource` WHERE %s ORDER BY `updated_ts` DESC, `created_ts` DESC", strings.Join(fields, ", "), strings.Join(where, " AND "))if find.Limit != nil {query = fmt.Sprintf("%s LIMIT %d", query, *find.Limit)if find.Offset != nil {@@ -72,6 +69,7 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*stvar memoID sql.NullInt32dests := []any{&resource.ID,+ &resource.ResourceName,&resource.Filename,&resource.ExternalLink,&resource.Type,@@ -104,32 +102,32 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*stfunc (d *DB) UpdateResource(ctx context.Context, update *store.UpdateResource) (*store.Resource, error) {set, args := []string{}, []any{}+ if v := update.ResourceName; v != nil {+ set, args = append(set, "`resource_name` = ?"), append(args, *v)+ }if v := update.UpdatedTs; v != nil {- set, args = append(set, "updated_ts = ?"), append(args, *v)+ set, args = append(set, "`updated_ts` = ?"), append(args, *v)}if v := update.Filename; v != nil {- set, args = append(set, "filename = ?"), append(args, *v)+ set, args = append(set, "`filename` = ?"), append(args, *v)}if v := update.InternalPath; v != nil {- set, args = append(set, "internal_path = ?"), append(args, *v)+ set, args = append(set, "`internal_path` = ?"), append(args, *v)}if v := update.MemoID; v != nil {- set, args = append(set, "memo_id = ?"), append(args, *v)+ set, args = append(set, "`memo_id` = ?"), append(args, *v)}if v := update.Blob; v != nil {- set, args = append(set, "blob = ?"), append(args, v)+ set, args = append(set, "`blob` = ?"), append(args, v)}args = append(args, update.ID)- fields := []string{"id", "filename", "external_link", "type", "size", "creator_id", "created_ts", "updated_ts", "internal_path"}- stmt := `- UPDATE resource- SET ` + strings.Join(set, ", ") + `- WHERE id = ?- RETURNING ` + strings.Join(fields, ", ")+ fields := []string{"`id`", "`resource_name`", "`filename`", "`external_link`", "`type`", "`size`", "`creator_id`", "`created_ts`", "`updated_ts`", "`internal_path`"}+ stmt := "UPDATE `resource` SET " + strings.Join(set, ", ") + " WHERE `id` = ? RETURNING " + strings.Join(fields, ", ")resource := store.Resource{}dests := []any{&resource.ID,+ &resource.ResourceName,&resource.Filename,&resource.ExternalLink,&resource.Type,@@ -147,10 +145,7 @@ func (d *DB) UpdateResource(ctx context.Context, update *store.UpdateResource) (}func (d *DB) DeleteResource(ctx context.Context, delete *store.DeleteResource) error {- stmt := `- DELETE FROM resource- WHERE id = ?- `+ stmt := "DELETE FROM `resource` WHERE `id` = ?"result, err := d.db.ExecContext(ctx, stmt, delete.ID)if err != nil {return err@@ -168,16 +163,7 @@ func (d *DB) DeleteResource(ctx context.Context, delete *store.DeleteResource) e}func vacuumResource(ctx context.Context, tx *sql.Tx) error {- stmt := `- DELETE FROM- resource- WHERE- creator_id NOT IN (- SELECT- id- FROM- user- )`+ stmt := "DELETE FROM `resource` WHERE `creator_id` NOT IN (SELECT `id` FROM `user`)"_, err := tx.ExecContext(ctx, stmt)if err != nil {return errdiff --git a/store/resource.go b/store/resource.goindex c2e2b21ff..371700845 100644--- a/store/resource.go+++ b/store/resource.go@@ -17,7 +17,8 @@ const ()type Resource struct {- ID int32+ ID int32+ ResourceName string// Standard fieldsCreatorID int32@@ -37,6 +38,7 @@ type Resource struct {type FindResource struct {GetBlob boolID *int32+ ResourceName *stringCreatorID *int32Filename *stringMemoID *int32@@ -47,6 +49,7 @@ type FindResource struct {type UpdateResource struct {ID int32+ ResourceName *stringUpdatedTs *int64Filename *stringInternalPath *string@@ -60,6 +63,9 @@ type DeleteResource struct {}func (s *Store) CreateResource(ctx context.Context, create *Resource) (*Resource, error) {+ if !util.ResourceNameMatcher.MatchString(create.ResourceName) {+ return nil, errors.New("invalid resource name")+ }return s.driver.CreateResource(ctx, create)}@@ -81,6 +87,9 @@ func (s *Store) GetResource(ctx context.Context, find *FindResource) (*Resource,}func (s *Store) UpdateResource(ctx context.Context, update *UpdateResource) (*Resource, error) {+ if update.ResourceName != nil && !util.ResourceNameMatcher.MatchString(*update.ResourceName) {+ return nil, errors.New("invalid resource name")+ }return s.driver.UpdateResource(ctx, update)}@@ -101,6 +110,7 @@ func (s *Store) DeleteResource(ctx context.Context, delete *DeleteResource) erro}_ = os.Remove(resourcePath)}+// Delete the thumbnail.if util.HasPrefixes(resource.Type, "image/png", "image/jpeg") {ext := filepath.Ext(resource.Filename)diff --git a/test/store/migrator_test.go b/test/store/migrator_test.goindex a971f28f8..0d71ca4fd 100644--- a/test/store/migrator_test.go+++ b/test/store/migrator_test.go@@ -4,6 +4,7 @@ import ("context""testing"+ "github.com/lithammer/shortuuid/v4""github.com/stretchr/testify/require""github.com/usememos/memos/store"@@ -33,6 +34,7 @@ func TestMigrateResourceInternalPath(t *testing.T) {for _, testCase := range testCases {for input, expectedOutput := range testCase {resourceCreate := &store.Resource{+ ResourceName: shortuuid.New(),CreatorID: user.ID,InternalPath: input,}diff --git a/test/store/resource_test.go b/test/store/resource_test.goindex e18831cff..90d66490a 100644--- a/test/store/resource_test.go+++ b/test/store/resource_test.go@@ -4,6 +4,7 @@ import ("context""testing"+ "github.com/lithammer/shortuuid/v4""github.com/stretchr/testify/require""github.com/usememos/memos/store"@@ -13,6 +14,7 @@ func TestResourceStore(t *testing.T) {ctx := context.Background()ts := NewTestingStore(ctx, t)_, err := ts.CreateResource(ctx, &store.Resource{+ ResourceName: shortuuid.New(),CreatorID: 101,Filename: "test.epub",Blob: []byte("test"),