mirror of
				https://github.com/usememos/memos.git
				synced 2025-06-05 22:09:59 +02:00 
			
		
		
		
	chore: update default storage back to database
This commit is contained in:
		| @@ -567,7 +567,7 @@ func SaveResourceBlob(ctx context.Context, s *store.Store, create *store.Resourc | |||||||
| 		return errors.Wrap(err, "Failed to find SystemSettingStorageServiceIDName") | 		return errors.Wrap(err, "Failed to find SystemSettingStorageServiceIDName") | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	storageServiceID := LocalStorage | 	storageServiceID := DefaultStorage | ||||||
| 	if systemSettingStorageServiceID != nil { | 	if systemSettingStorageServiceID != nil { | ||||||
| 		err = json.Unmarshal([]byte(systemSettingStorageServiceID.Value), &storageServiceID) | 		err = json.Unmarshal([]byte(systemSettingStorageServiceID.Value), &storageServiceID) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
|   | |||||||
| @@ -13,10 +13,11 @@ import ( | |||||||
|  |  | ||||||
| const ( | const ( | ||||||
| 	// LocalStorage means the storage service is local file system. | 	// LocalStorage means the storage service is local file system. | ||||||
| 	// Default storage service is local file system. |  | ||||||
| 	LocalStorage int32 = -1 | 	LocalStorage int32 = -1 | ||||||
| 	// DatabaseStorage means the storage service is database. | 	// DatabaseStorage means the storage service is database. | ||||||
| 	DatabaseStorage int32 = 0 | 	DatabaseStorage int32 = 0 | ||||||
|  | 	// Default storage service is database. | ||||||
|  | 	DefaultStorage int32 = DatabaseStorage | ||||||
| ) | ) | ||||||
|  |  | ||||||
| type StorageType string | 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) | 		return echo.NewHTTPError(http.StatusInternalServerError, "Failed to find storage").SetInternal(err) | ||||||
| 	} | 	} | ||||||
| 	if systemSetting != nil { | 	if systemSetting != nil { | ||||||
| 		storageServiceID := LocalStorage | 		storageServiceID := DefaultStorage | ||||||
| 		err = json.Unmarshal([]byte(systemSetting.Value), &storageServiceID) | 		err = json.Unmarshal([]byte(systemSetting.Value), &storageServiceID) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return echo.NewHTTPError(http.StatusInternalServerError, "Failed to unmarshal storage service id").SetInternal(err) | 			return echo.NewHTTPError(http.StatusInternalServerError, "Failed to unmarshal storage service id").SetInternal(err) | ||||||
|   | |||||||
| @@ -89,7 +89,7 @@ func (s *APIV1Service) GetSystemStatus(c echo.Context) error { | |||||||
| 			Appearance:  "system", | 			Appearance:  "system", | ||||||
| 			ExternalURL: "", | 			ExternalURL: "", | ||||||
| 		}, | 		}, | ||||||
| 		StorageServiceID:         LocalStorage, | 		StorageServiceID:         DefaultStorage, | ||||||
| 		LocalStoragePath:         "assets/{timestamp}_{filename}", | 		LocalStoragePath:         "assets/{timestamp}_{filename}", | ||||||
| 		MemoDisplayWithUpdatedTs: false, | 		MemoDisplayWithUpdatedTs: false, | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -39,7 +39,7 @@ func (s *ResourceService) ListResources(ctx context.Context, _ *apiv2pb.ListReso | |||||||
|  |  | ||||||
| 	response := &apiv2pb.ListResourcesResponse{} | 	response := &apiv2pb.ListResourcesResponse{} | ||||||
| 	for _, resource := range resources { | 	for _, resource := range resources { | ||||||
| 		response.Resources = append(response.Resources, convertResourceFromStore(resource)) | 		response.Resources = append(response.Resources, s.convertResourceFromStore(ctx, resource)) | ||||||
| 	} | 	} | ||||||
| 	return response, nil | 	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 nil, status.Errorf(codes.Internal, "failed to update resource: %v", err) | ||||||
| 	} | 	} | ||||||
| 	return &apiv2pb.UpdateResourceResponse{ | 	return &apiv2pb.UpdateResourceResponse{ | ||||||
| 		Resource: convertResourceFromStore(resource), | 		Resource: s.convertResourceFromStore(ctx, resource), | ||||||
| 	}, nil | 	}, nil | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -90,7 +90,17 @@ func (s *ResourceService) DeleteResource(ctx context.Context, request *apiv2pb.D | |||||||
| 	return &apiv2pb.DeleteResourceResponse{}, nil | 	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{ | 	return &apiv2pb.Resource{ | ||||||
| 		Id:           resource.ID, | 		Id:           resource.ID, | ||||||
| 		CreatedTs:    timestamppb.New(time.Unix(resource.CreatedTs, 0)), | 		CreatedTs:    timestamppb.New(time.Unix(resource.CreatedTs, 0)), | ||||||
| @@ -98,6 +108,6 @@ func convertResourceFromStore(resource *store.Resource) *apiv2pb.Resource { | |||||||
| 		ExternalLink: resource.ExternalLink, | 		ExternalLink: resource.ExternalLink, | ||||||
| 		Type:         resource.Type, | 		Type:         resource.Type, | ||||||
| 		Size:         resource.Size, | 		Size:         resource.Size, | ||||||
| 		MemoId:       resource.MemoID, | 		MemoId:       memoID, | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -66,13 +66,13 @@ const StorageSection = () => { | |||||||
|           handleActiveStorageServiceChanged(Number(event.target.value)); |           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")} /> |           <Radio value={"-1"} label={t("setting.storage-section.type-local")} /> | ||||||
|           <IconButton size="sm" onClick={() => showUpdateLocalStorageDialog(systemStatus.localStoragePath)}> |           <IconButton size="sm" onClick={() => showUpdateLocalStorageDialog(systemStatus.localStoragePath)}> | ||||||
|             <Icon.PenBox className="w-4 h-auto" /> |             <Icon.PenBox className="w-4 h-auto" /> | ||||||
|           </IconButton> |           </IconButton> | ||||||
|         </div> |         </div> | ||||||
|         <Radio value={"0"} label={t("setting.storage-section.type-database")} /> |  | ||||||
|         {storageList.map((storage) => ( |         {storageList.map((storage) => ( | ||||||
|           <Radio key={storage.id} value={storage.id} label={storage.name} /> |           <Radio key={storage.id} value={storage.id} label={storage.name} /> | ||||||
|         ))} |         ))} | ||||||
|   | |||||||
| @@ -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"> |             <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} /> |               <UserAvatar className="mr-2" avatarUrl={user.avatarUrl} /> | ||||||
|               <div className="w-auto grow truncate flex mr-2 flex-col justify-center items-start"> |               <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> |               </div> | ||||||
|               <QRCodeSVG |               <QRCodeSVG | ||||||
|                 value={`${window.location.origin}/m/${memo.id}`} |                 value={`${window.location.origin}/m/${memo.id}`} | ||||||
|   | |||||||
| @@ -202,7 +202,7 @@ | |||||||
|     "storage-section": { |     "storage-section": { | ||||||
|       "current-storage": "Current object storage", |       "current-storage": "Current object storage", | ||||||
|       "type-database": "Database", |       "type-database": "Database", | ||||||
|       "type-local": "Local", |       "type-local": "Local file system", | ||||||
|       "storage-services-list": "Storage service list", |       "storage-services-list": "Storage service list", | ||||||
|       "create-a-service": "Create a service", |       "create-a-service": "Create a service", | ||||||
|       "update-a-service": "Update a service", |       "update-a-service": "Update a service", | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user