Skip to content

armgit / memos

Public Imported from GitHub
0

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.

chore: update default storage back to database

Steven34ae9b06872c
diff --git a/api/v1/resource.go b/api/v1/resource.go
index 3d551640c..b2f4f9a64 100644
--- a/api/v1/resource.go
+++ b/api/v1/resource.go
@@ -567,7 +567,7 @@ func SaveResourceBlob(ctx context.Context, s *store.Store, create *store.Resourc
return errors.Wrap(err, "Failed to find SystemSettingStorageServiceIDName")
}
- storageServiceID := LocalStorage
+ storageServiceID := DefaultStorage
if systemSettingStorageServiceID != nil {
err = json.Unmarshal([]byte(systemSettingStorageServiceID.Value), &storageServiceID)
if err != nil {
diff --git a/api/v1/storage.go b/api/v1/storage.go
index e3c8180fb..8301eae32 100644
--- a/api/v1/storage.go
+++ b/api/v1/storage.go
@@ -13,10 +13,11 @@ import (
const (
// LocalStorage means the storage service is local file system.
- // Default storage service is local file system.
LocalStorage int32 = -1
// DatabaseStorage means the storage service is database.
DatabaseStorage int32 = 0
+ // Default storage service is database.
+ DefaultStorage int32 = DatabaseStorage
)
type StorageType string
@@ -212,7 +213,7 @@ func (s *APIV1Service) DeleteStorage(c echo.Context) error {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to find storage").SetInternal(err)
}
if systemSetting != nil {
- storageServiceID := LocalStorage
+ storageServiceID := DefaultStorage
err = json.Unmarshal([]byte(systemSetting.Value), &storageServiceID)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to unmarshal storage service id").SetInternal(err)
diff --git a/api/v1/system.go b/api/v1/system.go
index 0c0cb7a34..adbb438e9 100644
--- a/api/v1/system.go
+++ b/api/v1/system.go
@@ -89,7 +89,7 @@ func (s *APIV1Service) GetSystemStatus(c echo.Context) error {
Appearance: "system",
ExternalURL: "",
},
- StorageServiceID: LocalStorage,
+ StorageServiceID: DefaultStorage,
LocalStoragePath: "assets/{timestamp}_{filename}",
MemoDisplayWithUpdatedTs: false,
}
diff --git a/api/v2/resource_service.go b/api/v2/resource_service.go
index 3c550767e..209dede43 100644
--- a/api/v2/resource_service.go
+++ b/api/v2/resource_service.go
@@ -39,7 +39,7 @@ func (s *ResourceService) ListResources(ctx context.Context, _ *apiv2pb.ListReso
response := &apiv2pb.ListResourcesResponse{}
for _, resource := range resources {
- response.Resources = append(response.Resources, convertResourceFromStore(resource))
+ response.Resources = append(response.Resources, s.convertResourceFromStore(ctx, resource))
}
return response, nil
}
@@ -63,7 +63,7 @@ func (s *ResourceService) UpdateResource(ctx context.Context, request *apiv2pb.U
return nil, status.Errorf(codes.Internal, "failed to update resource: %v", err)
}
return &apiv2pb.UpdateResourceResponse{
- Resource: convertResourceFromStore(resource),
+ Resource: s.convertResourceFromStore(ctx, resource),
}, nil
}
@@ -90,7 +90,17 @@ func (s *ResourceService) DeleteResource(ctx context.Context, request *apiv2pb.D
return &apiv2pb.DeleteResourceResponse{}, nil
}
-func convertResourceFromStore(resource *store.Resource) *apiv2pb.Resource {
+func (s *ResourceService) convertResourceFromStore(ctx context.Context, resource *store.Resource) *apiv2pb.Resource {
+ var memoID *int32
+ if resource.MemoID != nil {
+ memo, _ := s.Store.GetMemo(ctx, &store.FindMemo{
+ ID: resource.MemoID,
+ })
+ if memo != nil {
+ memoID = &memo.ID
+ }
+ }
+
return &apiv2pb.Resource{
Id: resource.ID,
CreatedTs: timestamppb.New(time.Unix(resource.CreatedTs, 0)),
@@ -98,6 +108,6 @@ func convertResourceFromStore(resource *store.Resource) *apiv2pb.Resource {
ExternalLink: resource.ExternalLink,
Type: resource.Type,
Size: resource.Size,
- MemoId: resource.MemoID,
+ MemoId: memoID,
}
}
diff --git a/web/src/components/Settings/StorageSection.tsx b/web/src/components/Settings/StorageSection.tsx
index 7119c0e7d..6944ad5f9 100644
--- a/web/src/components/Settings/StorageSection.tsx
+++ b/web/src/components/Settings/StorageSection.tsx
@@ -66,13 +66,13 @@ const StorageSection = () => {
handleActiveStorageServiceChanged(Number(event.target.value));
}}
>
- <div className="w-full flex flex-row justify-start items-center gap-x-2">
+ <Radio value={"0"} label={t("setting.storage-section.type-database")} />
+ <div className="w-full mt-2 flex flex-row justify-start items-center gap-x-2">
<Radio value={"-1"} label={t("setting.storage-section.type-local")} />
<IconButton size="sm" onClick={() => showUpdateLocalStorageDialog(systemStatus.localStoragePath)}>
<Icon.PenBox className="w-4 h-auto" />
</IconButton>
</div>
- <Radio value={"0"} label={t("setting.storage-section.type-database")} />
{storageList.map((storage) => (
<Radio key={storage.id} value={storage.id} label={storage.name} />
))}
diff --git a/web/src/components/ShareMemoDialog.tsx b/web/src/components/ShareMemoDialog.tsx
index 6eb058a20..2b294dbc3 100644
--- a/web/src/components/ShareMemoDialog.tsx
+++ b/web/src/components/ShareMemoDialog.tsx
@@ -119,7 +119,7 @@ const ShareMemoDialog: React.FC<Props> = (props: Props) => {
<div className="flex flex-row justify-between items-center w-full bg-gray-100 dark:bg-zinc-700 py-4 px-6">
<UserAvatar className="mr-2" avatarUrl={user.avatarUrl} />
<div className="w-auto grow truncate flex mr-2 flex-col justify-center items-start">
- <span className="w-full text-sm truncate font-bold text-gray-600 dark:text-gray-300">{user.nickname || user.username}</span>
+ <span className="w-full text truncate font-medium text-gray-600 dark:text-gray-300">{user.nickname || user.username}</span>
</div>
<QRCodeSVG
value={`${window.location.origin}/m/${memo.id}`}
diff --git a/web/src/locales/en.json b/web/src/locales/en.json
index 5bd934d9f..e14ea2cd0 100644
--- a/web/src/locales/en.json
+++ b/web/src/locales/en.json
@@ -202,7 +202,7 @@
"storage-section": {
"current-storage": "Current object storage",
"type-database": "Database",
- "type-local": "Local",
+ "type-local": "Local file system",
"storage-services-list": "Storage service list",
"create-a-service": "Create a service",
"update-a-service": "Update a service",