mirror of
https://github.com/usememos/memos.git
synced 2026-11-19 10:29:11 +01:00
refactor: move the upload size limit to usage limits
The instance-wide maximum upload size in the storage setting and the per-user UPLOAD_BYTES usage limit were two caps on the same thing, with a rule that the per-user value could only lower the instance value. The storage setting field is removed, and the all-users UPLOAD_BYTES usage limit is the only per-file cap. A user's own limit replaces the default in either direction, and no limit means any file size. - Remove upload_size_limit_mb from the API and store storage settings, the 32 MiB store default, and the deployment config check. - Drop the FILE_TOO_LARGE error; every refusal is QUOTA_EXCEEDED with metric UPLOAD_BYTES. - Split usagelimit.CheckFileSize out of CheckUpload and call it from memo import, so import is no longer a bypass. - Remove the Maximum upload size field from the Storage section and the instance-limit warning from the usage limits dialog. The old value is not carried over. Instances that relied on the default accept any file size until an admin sets a limit.
This commit is contained in:
@@ -144,19 +144,34 @@ func CheckMemoCreate(ctx context.Context, s Store, userID int32) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// CheckUpload returns a *Refusal when storing a file of size bytes would break
|
||||
// the per-file limit or the storage limit of userID. instanceUploadLimit is
|
||||
// the instance-wide upload limit in bytes, which the caller checks first: a
|
||||
// per-file usage limit only applies when it is stricter than that limit. With
|
||||
// no storage limit in effect it runs no sum query.
|
||||
func CheckUpload(ctx context.Context, s Store, userID int32, size, instanceUploadLimit int64) error {
|
||||
// CheckFileSize returns a *Refusal when a file of size bytes is larger than
|
||||
// the per-file limit of userID. It runs no count or sum query.
|
||||
func CheckFileSize(ctx context.Context, s Store, userID int32, size int64) error {
|
||||
effective, err := EffectiveFor(ctx, s, userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if upload := effective.UploadBytes; upload.Limited() && upload.Value < instanceUploadLimit && size > upload.Value {
|
||||
return effective.checkFileSize(size)
|
||||
}
|
||||
|
||||
func (e Effective) checkFileSize(size int64) error {
|
||||
if upload := e.UploadBytes; upload.Limited() && size > upload.Value {
|
||||
return &Refusal{Metric: MetricUploadBytes, Limit: upload.Value, Usage: size, Source: upload.Source}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// CheckUpload returns a *Refusal when storing a file of size bytes would break
|
||||
// the per-file limit or the storage limit of userID. With no storage limit in
|
||||
// effect it runs no sum query.
|
||||
func CheckUpload(ctx context.Context, s Store, userID int32, size int64) error {
|
||||
effective, err := EffectiveFor(ctx, s, userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := effective.checkFileSize(size); err != nil {
|
||||
return err
|
||||
}
|
||||
if !effective.StorageBytes.Limited() {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -90,24 +90,33 @@ func TestCheckMemoCreate(t *testing.T) {
|
||||
|
||||
func TestCheckUpload(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
const instanceLimit = 30 << 20
|
||||
|
||||
unlimited := &fakeStore{storage: 1 << 40}
|
||||
require.NoError(t, CheckUpload(ctx, unlimited, 1, 1<<20, instanceLimit))
|
||||
require.NoError(t, CheckUpload(ctx, unlimited, 1, 1<<40), "no limits means any file size")
|
||||
require.Zero(t, unlimited.sumCalls, "no sum query runs without a storage limit")
|
||||
|
||||
s := &fakeStore{storage: 900, setting: &storepb.InstanceUsageLimitsSetting{Limits: []*storepb.InstanceUsageLimitsSetting_UsageLimit{
|
||||
limit("default-storage", MetricStorageBytes, 0, 1000),
|
||||
limit("default-upload", MetricUploadBytes, 0, 200),
|
||||
limit("alice-upload", MetricUploadBytes, 2, 500),
|
||||
}}}
|
||||
require.NoError(t, CheckUpload(ctx, s, 1, 100, instanceLimit), "exactly at the storage limit is allowed")
|
||||
require.Equal(t, &Refusal{Metric: MetricStorageBytes, Limit: 1000, Usage: 900, Source: "default-storage"}, AsRefusal(CheckUpload(ctx, s, 1, 101, instanceLimit)))
|
||||
require.Equal(t, &Refusal{Metric: MetricUploadBytes, Limit: 200, Usage: 201, Source: "default-upload"}, AsRefusal(CheckUpload(ctx, s, 1, 201, instanceLimit)))
|
||||
require.NoError(t, CheckUpload(ctx, s, 1, 100), "exactly at the storage limit is allowed")
|
||||
require.Equal(t, &Refusal{Metric: MetricStorageBytes, Limit: 1000, Usage: 900, Source: "default-storage"}, AsRefusal(CheckUpload(ctx, s, 1, 101)))
|
||||
require.Equal(t, &Refusal{Metric: MetricUploadBytes, Limit: 200, Usage: 201, Source: "default-upload"}, AsRefusal(CheckUpload(ctx, s, 1, 201)))
|
||||
|
||||
// A per-file limit at or above the instance limit has no effect; the
|
||||
// instance limit, checked by the caller, applies instead.
|
||||
s.setting.Limits[1].Value = instanceLimit
|
||||
// A user's own per-file limit replaces the default, even when it is higher.
|
||||
s.storage = 0
|
||||
s.setting.Limits[0].Value = 0
|
||||
require.NoError(t, CheckUpload(ctx, s, 1, instanceLimit, instanceLimit))
|
||||
require.NoError(t, CheckUpload(ctx, s, 2, 500))
|
||||
require.Equal(t, &Refusal{Metric: MetricUploadBytes, Limit: 500, Usage: 501, Source: "alice-upload"}, AsRefusal(CheckUpload(ctx, s, 2, 501)))
|
||||
}
|
||||
|
||||
func TestCheckFileSize(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
s := &fakeStore{storage: 1 << 40, setting: &storepb.InstanceUsageLimitsSetting{Limits: []*storepb.InstanceUsageLimitsSetting_UsageLimit{
|
||||
limit("default-storage", MetricStorageBytes, 0, 1),
|
||||
limit("default-upload", MetricUploadBytes, 0, 200),
|
||||
}}}
|
||||
require.NoError(t, CheckFileSize(ctx, s, 1, 200), "the storage limit is not checked")
|
||||
require.Equal(t, &Refusal{Metric: MetricUploadBytes, Limit: 200, Usage: 201, Source: "default-upload"}, AsRefusal(CheckFileSize(ctx, s, 1, 201)))
|
||||
require.Zero(t, s.sumCalls, "no sum query runs for a per-file check")
|
||||
}
|
||||
|
||||
@@ -279,14 +279,11 @@ message InstanceSetting {
|
||||
// Default is assets/{timestamp}_{uuid}_{filename}.
|
||||
string filepath_template = 3;
|
||||
|
||||
// The maximum upload size in megabytes. Default is 32.
|
||||
int64 upload_size_limit_mb = 4;
|
||||
|
||||
// Legacy compatibility field. New clients use default_storage_id.
|
||||
StorageType storage_type = 5;
|
||||
StorageType storage_type = 4;
|
||||
|
||||
// Legacy compatibility field. New clients use storages.
|
||||
S3Config s3_config = 6;
|
||||
S3Config s3_config = 5;
|
||||
|
||||
// StorageType is the legacy storage type, retained for compatibility with existing clients.
|
||||
enum StorageType {
|
||||
@@ -600,8 +597,7 @@ message UsageLimit {
|
||||
(google.api.resource_reference) = {type: "memos.api/User"}
|
||||
];
|
||||
|
||||
// Required. The limit. Must not be negative. 0 means unlimited for MEMOS and
|
||||
// STORAGE_BYTES, and no extra limit for UPLOAD_BYTES.
|
||||
// Required. The limit. Must not be negative. 0 means unlimited.
|
||||
int64 value = 4 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Output only. The creation time.
|
||||
@@ -619,8 +615,7 @@ message UsageLimit {
|
||||
// The total size in bytes of the user's uploads, including uploads not
|
||||
// attached to a memo. External links do not count.
|
||||
STORAGE_BYTES = 2;
|
||||
// The size in bytes of one uploaded file. It can only lower the instance
|
||||
// upload limit, never raise it.
|
||||
// The size in bytes of one uploaded file.
|
||||
UPLOAD_BYTES = 3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -711,14 +711,13 @@ message UserUsage {
|
||||
// The limit on storage_bytes.
|
||||
EffectiveLimit storage_bytes_limit = 5;
|
||||
|
||||
// The limit on the size of one uploaded file. It applies only when it is
|
||||
// lower than the instance upload limit.
|
||||
// The limit on the size of one uploaded file.
|
||||
EffectiveLimit upload_bytes_limit = 6;
|
||||
|
||||
// EffectiveLimit is the limit in effect for one metric, and where it comes
|
||||
// from.
|
||||
message EffectiveLimit {
|
||||
// The limit. 0 means unlimited, or no extra limit for upload_bytes_limit.
|
||||
// The limit. 0 means unlimited.
|
||||
int64 value = 1;
|
||||
|
||||
// The usage limit the value comes from: the user's own limit, or else the
|
||||
|
||||
@@ -326,8 +326,7 @@ const (
|
||||
// The total size in bytes of the user's uploads, including uploads not
|
||||
// attached to a memo. External links do not count.
|
||||
UsageLimit_STORAGE_BYTES UsageLimit_Metric = 2
|
||||
// The size in bytes of one uploaded file. It can only lower the instance
|
||||
// upload limit, never raise it.
|
||||
// The size in bytes of one uploaded file.
|
||||
UsageLimit_UPLOAD_BYTES UsageLimit_Metric = 3
|
||||
)
|
||||
|
||||
@@ -1071,8 +1070,7 @@ type UsageLimit struct {
|
||||
// Optional. Immutable. The user the limit applies to. Empty means every user.
|
||||
// Format: users/{user}
|
||||
User string `protobuf:"bytes,3,opt,name=user,proto3" json:"user,omitempty"`
|
||||
// Required. The limit. Must not be negative. 0 means unlimited for MEMOS and
|
||||
// STORAGE_BYTES, and no extra limit for UPLOAD_BYTES.
|
||||
// Required. The limit. Must not be negative. 0 means unlimited.
|
||||
Value int64 `protobuf:"varint,4,opt,name=value,proto3" json:"value,omitempty"`
|
||||
// Output only. The creation time.
|
||||
CreateTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"`
|
||||
@@ -1661,12 +1659,10 @@ type InstanceSetting_StorageSetting struct {
|
||||
// The template of attachment file paths.
|
||||
// Default is assets/{timestamp}_{uuid}_{filename}.
|
||||
FilepathTemplate string `protobuf:"bytes,3,opt,name=filepath_template,json=filepathTemplate,proto3" json:"filepath_template,omitempty"`
|
||||
// The maximum upload size in megabytes. Default is 32.
|
||||
UploadSizeLimitMb int64 `protobuf:"varint,4,opt,name=upload_size_limit_mb,json=uploadSizeLimitMb,proto3" json:"upload_size_limit_mb,omitempty"`
|
||||
// Legacy compatibility field. New clients use default_storage_id.
|
||||
StorageType InstanceSetting_StorageSetting_StorageType `protobuf:"varint,5,opt,name=storage_type,json=storageType,proto3,enum=memos.api.InstanceSetting_StorageSetting_StorageType" json:"storage_type,omitempty"`
|
||||
StorageType InstanceSetting_StorageSetting_StorageType `protobuf:"varint,4,opt,name=storage_type,json=storageType,proto3,enum=memos.api.InstanceSetting_StorageSetting_StorageType" json:"storage_type,omitempty"`
|
||||
// Legacy compatibility field. New clients use storages.
|
||||
S3Config *InstanceSetting_StorageSetting_S3Config `protobuf:"bytes,6,opt,name=s3_config,json=s3Config,proto3" json:"s3_config,omitempty"`
|
||||
S3Config *InstanceSetting_StorageSetting_S3Config `protobuf:"bytes,5,opt,name=s3_config,json=s3Config,proto3" json:"s3_config,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@@ -1722,13 +1718,6 @@ func (x *InstanceSetting_StorageSetting) GetFilepathTemplate() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *InstanceSetting_StorageSetting) GetUploadSizeLimitMb() int64 {
|
||||
if x != nil {
|
||||
return x.UploadSizeLimitMb
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *InstanceSetting_StorageSetting) GetStorageType() InstanceSetting_StorageSetting_StorageType {
|
||||
if x != nil {
|
||||
return x.StorageType
|
||||
@@ -2806,7 +2795,7 @@ const file_api_instance_service_proto_rawDesc = "" +
|
||||
"\tChallenge\x12\x1a\n" +
|
||||
"\bprovider\x18\x01 \x01(\tR\bprovider\x12\x19\n" +
|
||||
"\bsite_key\x18\x02 \x01(\tR\asiteKey\"\x1b\n" +
|
||||
"\x19GetInstanceProfileRequest\"\xf1!\n" +
|
||||
"\x19GetInstanceProfileRequest\"\xc0!\n" +
|
||||
"\x0fInstanceSetting\x12\x17\n" +
|
||||
"\x04name\x18\x01 \x01(\tB\x03\xe0A\bR\x04name\x12T\n" +
|
||||
"\x0fgeneral_setting\x18\x02 \x01(\v2).memos.api.InstanceSetting.GeneralSettingH\x00R\x0egeneralSetting\x12T\n" +
|
||||
@@ -2829,14 +2818,13 @@ const file_api_instance_service_proto_rawDesc = "" +
|
||||
"\rCustomProfile\x12\x14\n" +
|
||||
"\x05title\x18\x01 \x01(\tR\x05title\x12 \n" +
|
||||
"\vdescription\x18\x02 \x01(\tR\vdescription\x12\x19\n" +
|
||||
"\blogo_url\x18\x03 \x01(\tR\alogoUrl\x1a\xe2\x05\n" +
|
||||
"\blogo_url\x18\x03 \x01(\tR\alogoUrl\x1a\xb1\x05\n" +
|
||||
"\x0eStorageSetting\x12>\n" +
|
||||
"\bstorages\x18\x01 \x03(\v2\".memos.api.InstanceSetting.StorageR\bstorages\x12,\n" +
|
||||
"\x12default_storage_id\x18\x02 \x01(\tR\x10defaultStorageId\x12+\n" +
|
||||
"\x11filepath_template\x18\x03 \x01(\tR\x10filepathTemplate\x12/\n" +
|
||||
"\x14upload_size_limit_mb\x18\x04 \x01(\x03R\x11uploadSizeLimitMb\x12X\n" +
|
||||
"\fstorage_type\x18\x05 \x01(\x0e25.memos.api.InstanceSetting.StorageSetting.StorageTypeR\vstorageType\x12O\n" +
|
||||
"\ts3_config\x18\x06 \x01(\v22.memos.api.InstanceSetting.StorageSetting.S3ConfigR\bs3Config\x1a\x8a\x02\n" +
|
||||
"\x11filepath_template\x18\x03 \x01(\tR\x10filepathTemplate\x12X\n" +
|
||||
"\fstorage_type\x18\x04 \x01(\x0e25.memos.api.InstanceSetting.StorageSetting.StorageTypeR\vstorageType\x12O\n" +
|
||||
"\ts3_config\x18\x05 \x01(\v22.memos.api.InstanceSetting.StorageSetting.S3ConfigR\bs3Config\x1a\x8a\x02\n" +
|
||||
"\bS3Config\x12\x1a\n" +
|
||||
"\bendpoint\x18\x01 \x01(\tR\bendpoint\x12\x16\n" +
|
||||
"\x06region\x18\x02 \x01(\tR\x06region\x12\x16\n" +
|
||||
|
||||
@@ -1619,8 +1619,7 @@ type UserUsage struct {
|
||||
MemosLimit *UserUsage_EffectiveLimit `protobuf:"bytes,4,opt,name=memos_limit,json=memosLimit,proto3" json:"memos_limit,omitempty"`
|
||||
// The limit on storage_bytes.
|
||||
StorageBytesLimit *UserUsage_EffectiveLimit `protobuf:"bytes,5,opt,name=storage_bytes_limit,json=storageBytesLimit,proto3" json:"storage_bytes_limit,omitempty"`
|
||||
// The limit on the size of one uploaded file. It applies only when it is
|
||||
// lower than the instance upload limit.
|
||||
// The limit on the size of one uploaded file.
|
||||
UploadBytesLimit *UserUsage_EffectiveLimit `protobuf:"bytes,6,opt,name=upload_bytes_limit,json=uploadBytesLimit,proto3" json:"upload_bytes_limit,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -4611,7 +4610,7 @@ func (x *UserStats_MemoTypeStats) GetUndoCount() int32 {
|
||||
// from.
|
||||
type UserUsage_EffectiveLimit struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// The limit. 0 means unlimited, or no extra limit for upload_bytes_limit.
|
||||
// The limit. 0 means unlimited.
|
||||
Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
|
||||
// The usage limit the value comes from: the user's own limit, or else the
|
||||
// default. Empty when no usage limit applies.
|
||||
|
||||
+3
-10
@@ -4251,9 +4251,6 @@ components:
|
||||
description: |-
|
||||
The template of attachment file paths.
|
||||
Default is assets/{timestamp}_{uuid}_{filename}.
|
||||
uploadSizeLimitMb:
|
||||
type: string
|
||||
description: The maximum upload size in megabytes. Default is 32.
|
||||
storageType:
|
||||
enum:
|
||||
- STORAGE_TYPE_UNSPECIFIED
|
||||
@@ -5575,9 +5572,7 @@ components:
|
||||
Format: users/{user}
|
||||
value:
|
||||
type: string
|
||||
description: |-
|
||||
Required. The limit. Must not be negative. 0 means unlimited for MEMOS and
|
||||
STORAGE_BYTES, and no extra limit for UPLOAD_BYTES.
|
||||
description: Required. The limit. Must not be negative. 0 means unlimited.
|
||||
createTime:
|
||||
readOnly: true
|
||||
type: string
|
||||
@@ -5964,16 +5959,14 @@ components:
|
||||
uploadBytesLimit:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/UserUsage_EffectiveLimit'
|
||||
description: |-
|
||||
The limit on the size of one uploaded file. It applies only when it is
|
||||
lower than the instance upload limit.
|
||||
description: The limit on the size of one uploaded file.
|
||||
description: UserUsage is a user's usage and the usage limits in effect for the user.
|
||||
UserUsage_EffectiveLimit:
|
||||
type: object
|
||||
properties:
|
||||
value:
|
||||
type: string
|
||||
description: The limit. 0 means unlimited, or no extra limit for upload_bytes_limit.
|
||||
description: The limit. 0 means unlimited.
|
||||
usageLimit:
|
||||
type: string
|
||||
description: |-
|
||||
|
||||
@@ -321,8 +321,7 @@ const (
|
||||
// STORAGE_BYTES limits the total size of a user's uploads. External links
|
||||
// do not count.
|
||||
InstanceUsageLimitsSetting_STORAGE_BYTES InstanceUsageLimitsSetting_Metric = 2
|
||||
// UPLOAD_BYTES limits the size of one uploaded file. It can only lower the
|
||||
// instance upload limit.
|
||||
// UPLOAD_BYTES limits the size of one uploaded file.
|
||||
InstanceUsageLimitsSetting_UPLOAD_BYTES InstanceUsageLimitsSetting_Metric = 3
|
||||
)
|
||||
|
||||
@@ -895,15 +894,13 @@ type InstanceStorageSetting struct {
|
||||
// The template of file path.
|
||||
// e.g. assets/{timestamp}_{filename}
|
||||
FilepathTemplate string `protobuf:"bytes,2,opt,name=filepath_template,json=filepathTemplate,proto3" json:"filepath_template,omitempty"`
|
||||
// The max upload size in megabytes.
|
||||
UploadSizeLimitMb int64 `protobuf:"varint,3,opt,name=upload_size_limit_mb,json=uploadSizeLimitMb,proto3" json:"upload_size_limit_mb,omitempty"`
|
||||
// Legacy compatibility field. New code uses storages.
|
||||
S3Config *StorageS3Config `protobuf:"bytes,4,opt,name=s3_config,json=s3Config,proto3" json:"s3_config,omitempty"`
|
||||
S3Config *StorageS3Config `protobuf:"bytes,3,opt,name=s3_config,json=s3Config,proto3" json:"s3_config,omitempty"`
|
||||
// storages contains configured storage instances, including inactive instances
|
||||
// that may still be referenced by existing attachments.
|
||||
Storages []*Storage `protobuf:"bytes,5,rep,name=storages,proto3" json:"storages,omitempty"`
|
||||
Storages []*Storage `protobuf:"bytes,4,rep,name=storages,proto3" json:"storages,omitempty"`
|
||||
// default_storage_id identifies the storage used for new attachments.
|
||||
DefaultStorageId string `protobuf:"bytes,6,opt,name=default_storage_id,json=defaultStorageId,proto3" json:"default_storage_id,omitempty"`
|
||||
DefaultStorageId string `protobuf:"bytes,5,opt,name=default_storage_id,json=defaultStorageId,proto3" json:"default_storage_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@@ -952,13 +949,6 @@ func (x *InstanceStorageSetting) GetFilepathTemplate() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *InstanceStorageSetting) GetUploadSizeLimitMb() int64 {
|
||||
if x != nil {
|
||||
return x.UploadSizeLimitMb
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *InstanceStorageSetting) GetS3Config() *StorageS3Config {
|
||||
if x != nil {
|
||||
return x.S3Config
|
||||
@@ -1843,14 +1833,13 @@ const file_store_instance_setting_proto_rawDesc = "" +
|
||||
"\x04type\x18\x03 \x01(\x0e2\x18.memos.store.StorageTypeR\x04type\x12;\n" +
|
||||
"\ts3_config\x18\n" +
|
||||
" \x01(\v2\x1c.memos.store.StorageS3ConfigH\x00R\bs3ConfigB\b\n" +
|
||||
"\x06config\"\xb3\x03\n" +
|
||||
"\x06config\"\x82\x03\n" +
|
||||
"\x16InstanceStorageSetting\x12R\n" +
|
||||
"\fstorage_type\x18\x01 \x01(\x0e2/.memos.store.InstanceStorageSetting.StorageTypeR\vstorageType\x12+\n" +
|
||||
"\x11filepath_template\x18\x02 \x01(\tR\x10filepathTemplate\x12/\n" +
|
||||
"\x14upload_size_limit_mb\x18\x03 \x01(\x03R\x11uploadSizeLimitMb\x129\n" +
|
||||
"\ts3_config\x18\x04 \x01(\v2\x1c.memos.store.StorageS3ConfigR\bs3Config\x120\n" +
|
||||
"\bstorages\x18\x05 \x03(\v2\x14.memos.store.StorageR\bstorages\x12,\n" +
|
||||
"\x12default_storage_id\x18\x06 \x01(\tR\x10defaultStorageId\"L\n" +
|
||||
"\x11filepath_template\x18\x02 \x01(\tR\x10filepathTemplate\x129\n" +
|
||||
"\ts3_config\x18\x03 \x01(\v2\x1c.memos.store.StorageS3ConfigR\bs3Config\x120\n" +
|
||||
"\bstorages\x18\x04 \x03(\v2\x14.memos.store.StorageR\bstorages\x12,\n" +
|
||||
"\x12default_storage_id\x18\x05 \x01(\tR\x10defaultStorageId\"L\n" +
|
||||
"\vStorageType\x12\x1c\n" +
|
||||
"\x18STORAGE_TYPE_UNSPECIFIED\x10\x00\x12\f\n" +
|
||||
"\bDATABASE\x10\x01\x12\t\n" +
|
||||
|
||||
@@ -118,15 +118,13 @@ message InstanceStorageSetting {
|
||||
// The template of file path.
|
||||
// e.g. assets/{timestamp}_{filename}
|
||||
string filepath_template = 2;
|
||||
// The max upload size in megabytes.
|
||||
int64 upload_size_limit_mb = 3;
|
||||
// Legacy compatibility field. New code uses storages.
|
||||
StorageS3Config s3_config = 4;
|
||||
StorageS3Config s3_config = 3;
|
||||
// storages contains configured storage instances, including inactive instances
|
||||
// that may still be referenced by existing attachments.
|
||||
repeated Storage storages = 5;
|
||||
repeated Storage storages = 4;
|
||||
// default_storage_id identifies the storage used for new attachments.
|
||||
string default_storage_id = 6;
|
||||
string default_storage_id = 5;
|
||||
}
|
||||
|
||||
// Reference: https://developers.cloudflare.com/r2/examples/aws/aws-sdk-go/
|
||||
@@ -276,8 +274,7 @@ message InstanceUsageLimitsSetting {
|
||||
// STORAGE_BYTES limits the total size of a user's uploads. External links
|
||||
// do not count.
|
||||
STORAGE_BYTES = 2;
|
||||
// UPLOAD_BYTES limits the size of one uploaded file. It can only lower the
|
||||
// instance upload limit.
|
||||
// UPLOAD_BYTES limits the size of one uploaded file.
|
||||
UPLOAD_BYTES = 3;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ const maxGeneralRequestBytes = 16 << 20
|
||||
|
||||
// inlineContentProcedures carry a whole file in one request body and keep
|
||||
// the large cap; the size of that content is checked again by the handler
|
||||
// against the instance upload limit.
|
||||
// against the user's upload limits.
|
||||
var inlineContentProcedures = map[string]struct{}{
|
||||
"/memos.api.AttachmentService/CreateAttachment": {},
|
||||
"/memos.api.AIService/Transcribe": {},
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"context"
|
||||
"io"
|
||||
"log/slog"
|
||||
"math"
|
||||
"mime"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
@@ -25,9 +24,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// DefaultUploadSizeLimitBytes applies when no upload size limit is configured.
|
||||
DefaultUploadSizeLimitBytes = 32 << 20
|
||||
MebiByte = 1024 * 1024
|
||||
MebiByte = 1024 * 1024
|
||||
|
||||
// defaultJPEGQuality is the JPEG quality used when re-encoding images for EXIF stripping.
|
||||
// Quality 95 maintains visual quality while ensuring metadata is removed.
|
||||
@@ -176,30 +173,13 @@ func (s *APIService) CreateAttachment(ctx context.Context, request *apipb.Create
|
||||
return nil, status.Errorf(codes.Internal, "failed to get instance storage setting: %v", err)
|
||||
}
|
||||
content := request.Attachment.Content
|
||||
if err := checkUploadSize(instanceStorageSetting, int64(len(content))); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := s.checkUploadQuota(ctx, create.CreatorID, int64(len(content)), instanceStorageSetting); err != nil {
|
||||
if err := s.checkUploadQuota(ctx, create.CreatorID, int64(len(content))); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
create.Size = int64(len(content))
|
||||
return s.processAndSaveAttachment(ctx, create, instanceStorageSetting, bytes.NewReader(content))
|
||||
}
|
||||
|
||||
func attachmentUploadLimit(setting *storepb.InstanceStorageSetting) int64 {
|
||||
if setting.UploadSizeLimitMb <= 0 {
|
||||
return DefaultUploadSizeLimitBytes
|
||||
}
|
||||
return min(setting.UploadSizeLimitMb, math.MaxInt64/MebiByte) * MebiByte
|
||||
}
|
||||
|
||||
func checkUploadSize(setting *storepb.InstanceStorageSetting, size int64) error {
|
||||
if limit := attachmentUploadLimit(setting); size > limit {
|
||||
return newFileTooLargeError(limit, size)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// attachmentSource is the file content handed to the processing pipeline: a
|
||||
// bytes.Reader for the one-shot RPC, an *os.File for a chunked upload.
|
||||
type attachmentSource interface {
|
||||
|
||||
@@ -121,14 +121,7 @@ func (s *APIService) startAttachmentUpload(ctx context.Context, request *apipb.U
|
||||
if int64(len(request.Data)) > spec.TotalSize {
|
||||
return "", nil, status.Errorf(codes.InvalidArgument, "data exceeds total_size")
|
||||
}
|
||||
setting, err := s.Store.GetInstanceStorageSetting(ctx)
|
||||
if err != nil {
|
||||
return "", nil, status.Errorf(codes.Internal, "failed to get storage setting: %v", err)
|
||||
}
|
||||
if err := checkUploadSize(setting, spec.TotalSize); err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
if err := s.checkUploadQuota(ctx, ownerID, spec.TotalSize, setting); err != nil {
|
||||
if err := s.checkUploadQuota(ctx, ownerID, spec.TotalSize); err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
// Validate before allocating a temporary file. Keep the original MIME type
|
||||
@@ -162,18 +155,15 @@ func (s *APIService) finishAttachmentUpload(ctx context.Context, upload *attachm
|
||||
return s.GetAttachment(ctx, &apipb.GetAttachmentRequest{Name: "attachments/" + upload.state.uid})
|
||||
}
|
||||
}
|
||||
// Check again at finish: the limits may have changed, and other uploads
|
||||
// of the same user may have finished since this one started.
|
||||
if err := s.checkUploadQuota(ctx, upload.ownerID, upload.totalSize); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
setting, err := s.Store.GetInstanceStorageSetting(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to get storage setting: %v", err)
|
||||
}
|
||||
if err := checkUploadSize(setting, upload.totalSize); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Check again at finish: other uploads of the same user may have finished
|
||||
// since this one started.
|
||||
if err := s.checkUploadQuota(ctx, upload.ownerID, upload.totalSize, setting); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
file, err := os.Open(upload.path)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to open upload file: %v", err)
|
||||
|
||||
@@ -149,6 +149,10 @@ func TestUploadAttachmentValidation(t *testing.T) {
|
||||
}
|
||||
_, err = svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadSpec("file", 3), WriteOffset: 1, Data: []byte("abc")})
|
||||
require.Equal(t, codes.OutOfRange, status.Code(err))
|
||||
_, err = svc.Store.CreateUsageLimit(ctx, &storepb.InstanceUsageLimitsSetting_UsageLimit{
|
||||
Uid: "default-upload", Metric: storepb.InstanceUsageLimitsSetting_UPLOAD_BYTES, Value: 1 << 30,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
_, err = svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadSpec("file", 1<<60)})
|
||||
require.Equal(t, codes.ResourceExhausted, status.Code(err))
|
||||
require.Empty(t, svc.attachmentUploads.entries, "rejected spec calls must not register uploads")
|
||||
@@ -234,9 +238,10 @@ func TestUploadAttachmentRechecksMemoAndSize(t *testing.T) {
|
||||
_, err = svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadID(initial.UploadId), Data: []byte("abc"), FinishWrite: true})
|
||||
require.Equal(t, codes.NotFound, status.Code(err))
|
||||
|
||||
// A per-file limit set after the upload started applies at finish.
|
||||
id := startTestUpload(ctx, t, svc, 2*MebiByte)
|
||||
_, err = svc.Store.UpsertInstanceSetting(ctx, &storepb.InstanceSetting{Key: storepb.InstanceSettingKey_STORAGE,
|
||||
Value: &storepb.InstanceSetting_StorageSetting{StorageSetting: &storepb.InstanceStorageSetting{UploadSizeLimitMb: 1}},
|
||||
_, err = svc.Store.CreateUsageLimit(ctx, &storepb.InstanceUsageLimitsSetting_UsageLimit{
|
||||
Uid: "default-upload", Metric: storepb.InstanceUsageLimitsSetting_UPLOAD_BYTES, Value: MebiByte,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
_, err = svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{Upload: uploadID(id), Data: make([]byte, 2*MebiByte), FinishWrite: true})
|
||||
@@ -288,13 +293,10 @@ func TestUploadAttachmentExpiryAndLimits(t *testing.T) {
|
||||
func TestUploadAttachmentAboveLegacyRequestLimit(t *testing.T) {
|
||||
svc, ctx := newUploadTestService(t)
|
||||
const size = 300 * MebiByte
|
||||
_, err := svc.Store.UpsertInstanceSetting(ctx, &storepb.InstanceSetting{Key: storepb.InstanceSettingKey_STORAGE,
|
||||
Value: &storepb.InstanceSetting_StorageSetting{StorageSetting: &storepb.InstanceStorageSetting{UploadSizeLimitMb: 400}},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
id := startTestUpload(ctx, t, svc, size)
|
||||
chunk := bytes.Repeat([]byte{0x5a}, uploadChunkSize)
|
||||
var response *apipb.UploadAttachmentResponse
|
||||
var err error
|
||||
for offset := int64(0); offset < size; offset += int64(len(chunk)) {
|
||||
response, err = svc.UploadAttachment(ctx, &apipb.UploadAttachmentRequest{
|
||||
Upload: uploadID(id), WriteOffset: offset, Data: chunk, FinishWrite: offset+int64(len(chunk)) == size,
|
||||
|
||||
@@ -163,10 +163,9 @@ func convertInstanceStorageSettingFromStore(settingpb *storepb.InstanceStorageSe
|
||||
return nil
|
||||
}
|
||||
setting := &apipb.InstanceSetting_StorageSetting{
|
||||
StorageType: apipb.InstanceSetting_StorageSetting_StorageType(settingpb.StorageType),
|
||||
FilepathTemplate: settingpb.FilepathTemplate,
|
||||
UploadSizeLimitMb: settingpb.UploadSizeLimitMb,
|
||||
DefaultStorageId: settingpb.DefaultStorageId,
|
||||
StorageType: apipb.InstanceSetting_StorageSetting_StorageType(settingpb.StorageType),
|
||||
FilepathTemplate: settingpb.FilepathTemplate,
|
||||
DefaultStorageId: settingpb.DefaultStorageId,
|
||||
}
|
||||
for _, storagepb := range settingpb.Storages {
|
||||
setting.Storages = append(setting.Storages, convertStorageFromStore(storagepb))
|
||||
@@ -190,10 +189,9 @@ func convertInstanceStorageSettingToStore(setting *apipb.InstanceSetting_Storage
|
||||
return nil
|
||||
}
|
||||
settingpb := &storepb.InstanceStorageSetting{
|
||||
StorageType: storepb.InstanceStorageSetting_StorageType(setting.StorageType),
|
||||
FilepathTemplate: setting.FilepathTemplate,
|
||||
UploadSizeLimitMb: setting.UploadSizeLimitMb,
|
||||
DefaultStorageId: setting.DefaultStorageId,
|
||||
StorageType: storepb.InstanceStorageSetting_StorageType(setting.StorageType),
|
||||
FilepathTemplate: setting.FilepathTemplate,
|
||||
DefaultStorageId: setting.DefaultStorageId,
|
||||
}
|
||||
for _, storage := range setting.Storages {
|
||||
settingpb.Storages = append(settingpb.Storages, convertStorageToStore(storage))
|
||||
|
||||
@@ -34,9 +34,6 @@ const (
|
||||
// reasonQuotaExceeded marks a refusal by a usage limit. It does not recover
|
||||
// with time: the user must free space or an admin must raise the limit.
|
||||
reasonQuotaExceeded = "QUOTA_EXCEEDED"
|
||||
// reasonFileTooLarge marks a file larger than the instance upload limit,
|
||||
// which applies to every user.
|
||||
reasonFileTooLarge = "FILE_TOO_LARGE"
|
||||
// reasonChallengeRequired marks a request that must carry a valid challenge token.
|
||||
reasonChallengeRequired = "CHALLENGE_REQUIRED"
|
||||
|
||||
@@ -105,26 +102,6 @@ func newQuotaExceededError(username string, refusal *usagelimit.Refusal) error {
|
||||
return detailed.Err()
|
||||
}
|
||||
|
||||
// newFileTooLargeError builds the refusal for a file larger than the instance
|
||||
// upload limit: RESOURCE_EXHAUSTED with an ErrorInfo carrying the limit and
|
||||
// the file size in bytes. It carries no RetryInfo, because waiting does not
|
||||
// make the file fit.
|
||||
func newFileTooLargeError(limit, size int64) error {
|
||||
st := status.New(codes.ResourceExhausted, "file size exceeds the limit")
|
||||
detailed, err := st.WithDetails(&errdetails.ErrorInfo{
|
||||
Reason: reasonFileTooLarge,
|
||||
Domain: errorInfoDomain,
|
||||
Metadata: map[string]string{
|
||||
"limit": strconv.FormatInt(limit, 10),
|
||||
"size": strconv.FormatInt(size, 10),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return st.Err()
|
||||
}
|
||||
return detailed.Err()
|
||||
}
|
||||
|
||||
func quotaExceededDescription(refusal *usagelimit.Refusal) string {
|
||||
switch refusal.Metric {
|
||||
case usagelimit.MetricMemos:
|
||||
|
||||
@@ -246,10 +246,9 @@ func upsertS3StorageSetting(ctx context.Context, t testing.TB, ts *TestService,
|
||||
Key: storepb.InstanceSettingKey_STORAGE,
|
||||
Value: &storepb.InstanceSetting_StorageSetting{
|
||||
StorageSetting: &storepb.InstanceStorageSetting{
|
||||
FilepathTemplate: "attachments/{uuid}_{filename}",
|
||||
UploadSizeLimitMb: 30,
|
||||
Storages: storages,
|
||||
DefaultStorageId: defaultStorageID,
|
||||
FilepathTemplate: "attachments/{uuid}_{filename}",
|
||||
Storages: storages,
|
||||
DefaultStorageId: defaultStorageID,
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -267,7 +266,7 @@ func TestS3ObjectKeysStayUniqueWithoutUUIDTemplate(t *testing.T) {
|
||||
_, err := ts.Store.UpsertInstanceSetting(ctx, &storepb.InstanceSetting{
|
||||
Key: storepb.InstanceSettingKey_STORAGE,
|
||||
Value: &storepb.InstanceSetting_StorageSetting{StorageSetting: &storepb.InstanceStorageSetting{
|
||||
FilepathTemplate: "files/{filename}", UploadSizeLimitMb: 30, Storages: []*storepb.Storage{storage}, DefaultStorageId: storage.Id,
|
||||
FilepathTemplate: "files/{filename}", Storages: []*storepb.Storage{storage}, DefaultStorageId: storage.Id,
|
||||
}},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -49,7 +49,6 @@ func TestDeploymentConfiguredResourcesRejectMutations(t *testing.T) {
|
||||
require.Equal(t, int32(1), setting.GetGeneralSetting().WeekStartDayOffset)
|
||||
storageSetting, err := ts.Service.GetInstanceSetting(adminCtx, &apipb.GetInstanceSettingRequest{Name: "instance/settings/STORAGE"})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, int64(32), storageSetting.GetStorageSetting().UploadSizeLimitMb)
|
||||
require.Equal(t, "assets/{timestamp}_{uuid}_{filename}", storageSetting.GetStorageSetting().FilepathTemplate)
|
||||
|
||||
_, err = ts.Service.CreateIdentityProvider(adminCtx, &apipb.CreateIdentityProviderRequest{
|
||||
|
||||
@@ -604,16 +604,16 @@ func buildImportArchive(t *testing.T, username string, attachments []struct {
|
||||
return buf.Bytes()
|
||||
}
|
||||
|
||||
// A memo that fails to import must not take a pre-existing attachment of the
|
||||
// An archive entry larger than the user's per-file limit fails its memo, and
|
||||
// a memo that fails to import must not take a pre-existing attachment of the
|
||||
// user with it: only attachments the run stored are discarded.
|
||||
func TestImportMemosFailureKeepsPreexistingAttachment(t *testing.T) {
|
||||
ts := NewTestService(t)
|
||||
defer ts.Cleanup()
|
||||
t.Cleanup(ts.Service.CloseUploads)
|
||||
ctx := context.Background()
|
||||
_, err := ts.Store.UpsertInstanceSetting(ctx, &storepb.InstanceSetting{
|
||||
Key: storepb.InstanceSettingKey_STORAGE,
|
||||
Value: &storepb.InstanceSetting_StorageSetting{StorageSetting: &storepb.InstanceStorageSetting{UploadSizeLimitMb: 1}},
|
||||
_, err := ts.Store.CreateUsageLimit(ctx, &storepb.InstanceUsageLimitsSetting_UsageLimit{
|
||||
Uid: "default-upload", Metric: storepb.InstanceUsageLimitsSetting_UPLOAD_BYTES, Value: 1 << 20,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
user, err := ts.CreateRegularUser(ctx, "keeper")
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -397,21 +396,20 @@ func TestUploadLimitEnforcement(t *testing.T) {
|
||||
})
|
||||
require.Equal(t, codes.NotFound, status.Code(err), "a refused upload is revoked")
|
||||
|
||||
// A per-file limit above the instance upload limit has no effect: the
|
||||
// instance error applies unchanged.
|
||||
_, err = ts.Service.UpdateUsageLimit(adminCtx, &apipb.UpdateUsageLimitRequest{UsageLimit: &apipb.UsageLimit{Name: "usageLimits/default-upload", Value: 1 << 40}})
|
||||
require.NoError(t, err)
|
||||
// A user's own per-file limit replaces the default in either direction.
|
||||
_, err = ts.Service.UpdateUsageLimit(adminCtx, &apipb.UpdateUsageLimitRequest{UsageLimit: &apipb.UsageLimit{Name: "usageLimits/default-storage", Value: 0}})
|
||||
require.NoError(t, err)
|
||||
err = create(33 << 20)
|
||||
st := status.Convert(err)
|
||||
require.Equal(t, codes.ResourceExhausted, st.Code())
|
||||
require.Equal(t, "file size exceeds the limit", st.Message())
|
||||
require.Len(t, st.Details(), 1)
|
||||
info, ok := st.Details()[0].(*errdetails.ErrorInfo)
|
||||
require.True(t, ok, "the instance limit refusal carries an ErrorInfo")
|
||||
require.Equal(t, "FILE_TOO_LARGE", info.Reason)
|
||||
require.Equal(t, map[string]string{"limit": strconv.Itoa(32 << 20), "size": strconv.Itoa(33 << 20)}, info.Metadata)
|
||||
createUsageLimit(adminCtx, t, ts, "user-upload", apipb.UsageLimit_UPLOAD_BYTES, subject, 1<<20)
|
||||
require.NoError(t, create(1<<20))
|
||||
metadata = requireQuotaExceeded(t, create(1<<20+1), "UPLOAD_BYTES", subject)
|
||||
require.Equal(t, "usageLimits/user-upload", metadata["usage_limit"])
|
||||
|
||||
// Without any per-file limit, a file of any size is accepted.
|
||||
_, err = ts.Service.DeleteUsageLimit(adminCtx, &apipb.DeleteUsageLimitRequest{Name: "usageLimits/user-upload"})
|
||||
require.NoError(t, err)
|
||||
_, err = ts.Service.DeleteUsageLimit(adminCtx, &apipb.DeleteUsageLimitRequest{Name: "usageLimits/default-upload"})
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, create(33<<20))
|
||||
}
|
||||
|
||||
func TestGetUserUsagePermissions(t *testing.T) {
|
||||
|
||||
@@ -307,9 +307,20 @@ func (s *APIService) checkMemoQuota(ctx context.Context, user *store.User) error
|
||||
}
|
||||
|
||||
// checkUploadQuota refuses an upload of size bytes that would break the
|
||||
// per-file or storage limit of the user. Call it after checkUploadSize.
|
||||
func (s *APIService) checkUploadQuota(ctx context.Context, userID int32, size int64, setting *storepb.InstanceStorageSetting) error {
|
||||
err := usagelimit.CheckUpload(ctx, s.Store, userID, size, attachmentUploadLimit(setting))
|
||||
// per-file or storage limit of the user.
|
||||
func (s *APIService) checkUploadQuota(ctx context.Context, userID int32, size int64) error {
|
||||
return s.uploadQuotaError(ctx, userID, usagelimit.CheckUpload(ctx, s.Store, userID, size))
|
||||
}
|
||||
|
||||
// checkFileSizeQuota refuses a file of size bytes that is larger than the
|
||||
// per-file limit of the user. It runs no count or sum query.
|
||||
func (s *APIService) checkFileSizeQuota(ctx context.Context, userID int32, size int64) error {
|
||||
return s.uploadQuotaError(ctx, userID, usagelimit.CheckFileSize(ctx, s.Store, userID, size))
|
||||
}
|
||||
|
||||
// uploadQuotaError maps an upload check result to a service error, naming the
|
||||
// user in a refusal.
|
||||
func (s *APIService) uploadQuotaError(ctx context.Context, userID int32, err error) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -501,7 +501,7 @@ func (i *memoImporter) storeAttachment(entry *memoexport.Attachment, uid, mimeTy
|
||||
}
|
||||
return AttachmentNamePrefix + attachment.UID, nil
|
||||
}
|
||||
if err := checkUploadSize(i.storageSetting, entry.Size); err != nil {
|
||||
if err := i.service.checkFileSizeQuota(i.ctx, i.user.ID, entry.Size); err != nil {
|
||||
return "", err
|
||||
}
|
||||
data, err := i.archive.ReadAttachment(entry)
|
||||
|
||||
@@ -52,10 +52,9 @@ func TestServeAttachmentFile_S3(t *testing.T) {
|
||||
_, err := stores.UpsertInstanceSetting(ctx, &storepb.InstanceSetting{
|
||||
Key: storepb.InstanceSettingKey_STORAGE,
|
||||
Value: &storepb.InstanceSetting_StorageSetting{StorageSetting: &storepb.InstanceStorageSetting{
|
||||
FilepathTemplate: "files/{uuid}_{filename}",
|
||||
UploadSizeLimitMb: 30,
|
||||
Storages: []*storepb.Storage{configuredStorage},
|
||||
DefaultStorageId: configuredStorage.Id,
|
||||
FilepathTemplate: "files/{uuid}_{filename}",
|
||||
Storages: []*storepb.Storage{configuredStorage},
|
||||
DefaultStorageId: configuredStorage.Id,
|
||||
}},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -239,9 +239,6 @@ func validateAndNormalizeDeploymentInstanceSetting(setting *storepb.InstanceSett
|
||||
return errors.New("storageSetting.s3Config is required for S3")
|
||||
}
|
||||
NormalizeInstanceStorageSetting(storage)
|
||||
if storage.UploadSizeLimitMb < 0 {
|
||||
return errors.New("storageSetting.uploadSizeLimitMb must not be negative")
|
||||
}
|
||||
defaultStorage := GetDefaultStorage(storage)
|
||||
if defaultStorage != nil && defaultStorage.Type == storepb.StorageType_STORAGE_TYPE_S3 {
|
||||
s3Config := defaultStorage.GetS3Config()
|
||||
|
||||
@@ -376,9 +376,8 @@ func (s *Store) GetInstanceAISetting(ctx context.Context) (*storepb.InstanceAISe
|
||||
}
|
||||
|
||||
const (
|
||||
defaultInstanceStorageType = storepb.InstanceStorageSetting_LOCAL
|
||||
defaultInstanceUploadSizeLimitMb = 32
|
||||
defaultInstanceFilepathTemplate = "assets/{timestamp}_{uuid}_{filename}"
|
||||
defaultInstanceStorageType = storepb.InstanceStorageSetting_LOCAL
|
||||
defaultInstanceFilepathTemplate = "assets/{timestamp}_{uuid}_{filename}"
|
||||
)
|
||||
|
||||
func (s *Store) GetInstanceStorageSetting(ctx context.Context) (*storepb.InstanceStorageSetting, error) {
|
||||
@@ -398,9 +397,6 @@ func (s *Store) GetInstanceStorageSetting(ctx context.Context) (*storepb.Instanc
|
||||
if instanceStorageSetting.StorageType == storepb.InstanceStorageSetting_STORAGE_TYPE_UNSPECIFIED {
|
||||
instanceStorageSetting.StorageType = defaultInstanceStorageType
|
||||
}
|
||||
if instanceStorageSetting.UploadSizeLimitMb == 0 {
|
||||
instanceStorageSetting.UploadSizeLimitMb = defaultInstanceUploadSizeLimitMb
|
||||
}
|
||||
if instanceStorageSetting.FilepathTemplate == "" {
|
||||
instanceStorageSetting.FilepathTemplate = defaultInstanceFilepathTemplate
|
||||
}
|
||||
|
||||
@@ -285,7 +285,6 @@ func TestInstanceSettingStorageSetting(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, storageSetting)
|
||||
require.Equal(t, storepb.InstanceStorageSetting_LOCAL, storageSetting.StorageType)
|
||||
require.Equal(t, int64(32), storageSetting.UploadSizeLimitMb)
|
||||
require.Equal(t, "assets/{timestamp}_{uuid}_{filename}", storageSetting.FilepathTemplate)
|
||||
|
||||
// Set custom storage setting
|
||||
@@ -293,9 +292,8 @@ func TestInstanceSettingStorageSetting(t *testing.T) {
|
||||
Key: storepb.InstanceSettingKey_STORAGE,
|
||||
Value: &storepb.InstanceSetting_StorageSetting{
|
||||
StorageSetting: &storepb.InstanceStorageSetting{
|
||||
StorageType: storepb.InstanceStorageSetting_LOCAL,
|
||||
UploadSizeLimitMb: 100,
|
||||
FilepathTemplate: "uploads/{date}/{filename}",
|
||||
StorageType: storepb.InstanceStorageSetting_LOCAL,
|
||||
FilepathTemplate: "uploads/{date}/{filename}",
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -305,7 +303,6 @@ func TestInstanceSettingStorageSetting(t *testing.T) {
|
||||
storageSetting, err = ts.GetInstanceStorageSetting(ctx)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, storepb.InstanceStorageSetting_LOCAL, storageSetting.StorageType)
|
||||
require.Equal(t, int64(100), storageSetting.UploadSizeLimitMb)
|
||||
require.Equal(t, "uploads/{date}/{filename}", storageSetting.FilepathTemplate)
|
||||
|
||||
ts.Close()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { getLimitErrorMessage } from "@/lib/error";
|
||||
import { getQuotaExceededMessage } from "@/lib/error";
|
||||
|
||||
export const errorService = {
|
||||
getErrorMessage(error: unknown): string {
|
||||
const limitMessage = getLimitErrorMessage(error);
|
||||
const limitMessage = getQuotaExceededMessage(error);
|
||||
if (limitMessage !== undefined) {
|
||||
return limitMessage;
|
||||
}
|
||||
|
||||
@@ -170,10 +170,6 @@ const StorageSection = () => {
|
||||
}, [originalSetting]);
|
||||
|
||||
const allowSaveStorageSetting = useMemo(() => {
|
||||
if (instanceStorageSetting.uploadSizeLimitMb <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (selectedStorageType === InstanceSetting_StorageType.LOCAL) {
|
||||
if (instanceStorageSetting.filepathTemplate.length === 0) {
|
||||
return false;
|
||||
@@ -193,19 +189,6 @@ const StorageSection = () => {
|
||||
return !isEqual(originalSetting, canonicalizeStorageSetting(instanceStorageSetting, originalSetting));
|
||||
}, [canReuseSelectedS3Secret, instanceStorageSetting, originalSetting, selectedS3Config, selectedStorageType]);
|
||||
|
||||
const handleMaxUploadSizeChanged = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
let num = parseInt(event.target.value);
|
||||
if (Number.isNaN(num)) {
|
||||
num = 0;
|
||||
}
|
||||
setInstanceStorageSetting((current) =>
|
||||
create(InstanceSetting_StorageSettingSchema, {
|
||||
...current,
|
||||
uploadSizeLimitMb: BigInt(num),
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
const handleFilepathTemplateChanged = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setInstanceStorageSetting((current) =>
|
||||
create(InstanceSetting_StorageSettingSchema, {
|
||||
@@ -357,14 +340,6 @@ const StorageSection = () => {
|
||||
</ul>
|
||||
</SettingPanel>
|
||||
|
||||
<SettingRow label={t("setting.system.max-upload-size")} tooltip={t("setting.system.max-upload-size-hint")}>
|
||||
<Input
|
||||
className="w-24 font-mono"
|
||||
value={String(instanceStorageSetting.uploadSizeLimitMb)}
|
||||
onChange={handleMaxUploadSizeChanged}
|
||||
/>
|
||||
</SettingRow>
|
||||
|
||||
{selectedStorageType !== InstanceSetting_StorageType.DATABASE && (
|
||||
<SettingRow
|
||||
label={t("setting.storage.filepath-template")}
|
||||
|
||||
@@ -10,7 +10,7 @@ import { handleError } from "@/lib/error";
|
||||
import { UsageLimit_Metric } from "@/types/proto/api/instance_service_pb";
|
||||
import type { User } from "@/types/proto/api/user_service_pb";
|
||||
import { useTranslate } from "@/utils/i18n";
|
||||
import { isFileSizeLimitIneffective, parseLimitInput, toLimitInput } from "./usageLimitValues";
|
||||
import { parseLimitInput, toLimitInput } from "./usageLimitValues";
|
||||
|
||||
type Inputs = Record<UsageLimit_Metric, string>;
|
||||
|
||||
@@ -23,8 +23,6 @@ interface Props {
|
||||
target: UsageLimitDialogTarget;
|
||||
/** The users that can be added, which are those without limits of their own. */
|
||||
candidates: User[];
|
||||
/** The instance upload limit in MiB, for the file size warning. */
|
||||
uploadLimitMiB: number;
|
||||
}
|
||||
|
||||
const userLabel = (user: User) => (user.displayName ? `${user.displayName} (@${user.username})` : `@${user.username}`);
|
||||
@@ -34,7 +32,7 @@ const userLabel = (user: User) => (user.displayName ? `${user.displayName} (@${u
|
||||
* means no limit. For one user, an empty field means the all-users limit
|
||||
* applies, and 0 means no limit for that user.
|
||||
*/
|
||||
function UsageLimitDialog({ open, onOpenChange, target, candidates, uploadLimitMiB }: Props) {
|
||||
function UsageLimitDialog({ open, onOpenChange, target, candidates }: Props) {
|
||||
const t = useTranslate();
|
||||
const { data: limits } = useUsageLimits({ enabled: open });
|
||||
const [pickedName, setPickedName] = useState("");
|
||||
@@ -78,13 +76,7 @@ function UsageLimitDialog({ open, onOpenChange, target, candidates, uploadLimitM
|
||||
value: value ? toLimitInput(metric, value) : t("setting.usage-limits.unlimited"),
|
||||
});
|
||||
};
|
||||
const warning = (metric: UsageLimit_Metric) => {
|
||||
if (isInvalid(metric)) return t("setting.usage-limits.invalid");
|
||||
if (metric === UsageLimit_Metric.UPLOAD_BYTES && isFileSizeLimitIneffective(inputs[metric], uploadLimitMiB)) {
|
||||
return t("setting.usage-limits.file-size-warning", { limit: uploadLimitMiB });
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
const warning = (metric: UsageLimit_Metric) => (isInvalid(metric) ? t("setting.usage-limits.invalid") : undefined);
|
||||
|
||||
const hasChanges = USAGE_LIMIT_METRICS.some((metric) => inputs[metric] !== savedInputs[metric]);
|
||||
const isValid = USAGE_LIMIT_METRICS.every((metric) => !isInvalid(metric));
|
||||
|
||||
@@ -6,12 +6,11 @@ import ConfirmDialog from "@/components/ConfirmDialog";
|
||||
import UserAvatar from "@/components/UserAvatar";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
|
||||
import { useInstanceSetting } from "@/hooks/useInstanceQueries";
|
||||
import { findUsageLimit, USAGE_LIMIT_METRICS, useSetUsageLimit, useUsageLimits } from "@/hooks/useUsageLimitQueries";
|
||||
import { useListUsers } from "@/hooks/useUserQueries";
|
||||
import { handleError } from "@/lib/error";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { InstanceSetting_Key, UsageLimit_Metric } from "@/types/proto/api/instance_service_pb";
|
||||
import { UsageLimit_Metric } from "@/types/proto/api/instance_service_pb";
|
||||
import { User } from "@/types/proto/api/user_service_pb";
|
||||
import { useTranslate } from "@/utils/i18n";
|
||||
import SettingSection from "./SettingSection";
|
||||
@@ -19,9 +18,6 @@ import SettingTable from "./SettingTable";
|
||||
import UsageLimitDialog, { type UsageLimitDialogTarget } from "./UsageLimitDialog";
|
||||
import { formatLimitValue } from "./usageLimitValues";
|
||||
|
||||
// The store applies 32 MiB when the instance upload limit is unset.
|
||||
const DEFAULT_UPLOAD_LIMIT_MIB = 32;
|
||||
|
||||
/**
|
||||
* A table row: name is empty for the all-users row, otherwise users/{user}.
|
||||
* The user is missing when the user list has not loaded.
|
||||
@@ -36,7 +32,6 @@ const UsageLimitsSection = () => {
|
||||
const t = useTranslate();
|
||||
const { data: limits, isLoading } = useUsageLimits();
|
||||
const { data: users = [] } = useListUsers();
|
||||
const { data: storageSetting } = useInstanceSetting(InstanceSetting_Key.STORAGE);
|
||||
const setUsageLimit = useSetUsageLimit();
|
||||
const [dialog, setDialog] = useState<{ open: boolean; target: UsageLimitDialogTarget }>({ open: false, target: { kind: "all" } });
|
||||
const [removeTarget, setRemoveTarget] = useState<LimitRow | undefined>();
|
||||
@@ -57,10 +52,6 @@ const UsageLimitsSection = () => {
|
||||
[users, userRows],
|
||||
);
|
||||
|
||||
const uploadLimitMiB =
|
||||
(storageSetting?.value.case === "storageSetting" ? Number(storageSetting.value.value.uploadSizeLimitMb) : 0) ||
|
||||
DEFAULT_UPLOAD_LIMIT_MIB;
|
||||
|
||||
const openDialog = (target: UsageLimitDialogTarget) => setDialog({ open: true, target });
|
||||
|
||||
const handleRemove = async () => {
|
||||
@@ -184,7 +175,6 @@ const UsageLimitsSection = () => {
|
||||
onOpenChange={(open) => setDialog((current) => ({ ...current, open }))}
|
||||
target={dialog.target}
|
||||
candidates={candidates}
|
||||
uploadLimitMiB={uploadLimitMiB}
|
||||
/>
|
||||
|
||||
<ConfirmDialog
|
||||
|
||||
@@ -150,7 +150,6 @@ export const SETTINGS_SECTIONS: SettingSectionDefinition[] = [
|
||||
labelKey: "setting.usage-limits.label",
|
||||
icon: GaugeIcon,
|
||||
component: UsageLimitsSection,
|
||||
preloadSettingKeys: [InstanceSetting_Key.STORAGE],
|
||||
},
|
||||
{
|
||||
key: "notification",
|
||||
|
||||
@@ -32,9 +32,3 @@ export function parseLimitInput(metric: UsageLimit_Metric, input: string): bigin
|
||||
export function formatLimitValue(metric: UsageLimit_Metric, value: bigint): string {
|
||||
return isByteMetric(metric) ? formatFileSize(Number(value)) : value.toLocaleString();
|
||||
}
|
||||
|
||||
/** Whether a file size limit, entered in MiB, is not below the instance upload limit and so has no effect. */
|
||||
export function isFileSizeLimitIneffective(input: string, instanceUploadLimitMiB: number): boolean {
|
||||
const value = parseLimitInput(UsageLimit_Metric.UPLOAD_BYTES, input);
|
||||
return value !== undefined && value > 0n && value >= BigInt(instanceUploadLimitMiB) * BigInt(MIB);
|
||||
}
|
||||
|
||||
+1
-19
@@ -12,7 +12,6 @@ export interface ErrorInfo {
|
||||
export const ERROR_REASON_RATE_LIMITED = "RATE_LIMITED";
|
||||
export const ERROR_REASON_CHALLENGE_REQUIRED = "CHALLENGE_REQUIRED";
|
||||
export const ERROR_REASON_QUOTA_EXCEEDED = "QUOTA_EXCEEDED";
|
||||
export const ERROR_REASON_FILE_TOO_LARGE = "FILE_TOO_LARGE";
|
||||
|
||||
const ERROR_INFO_TYPE = "google.rpc.ErrorInfo";
|
||||
|
||||
@@ -105,23 +104,6 @@ export function getQuotaExceededMessage(error: unknown): string | undefined {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes a refusal by a size or usage limit in words: QUOTA_EXCEEDED, or
|
||||
* FILE_TOO_LARGE for the instance upload limit. Returns undefined for any
|
||||
* other error.
|
||||
*/
|
||||
export function getLimitErrorMessage(error: unknown): string | undefined {
|
||||
const quotaMessage = getQuotaExceededMessage(error);
|
||||
if (quotaMessage !== undefined) {
|
||||
return quotaMessage;
|
||||
}
|
||||
const info = getErrorInfo(error);
|
||||
if (info?.reason !== ERROR_REASON_FILE_TOO_LARGE) {
|
||||
return undefined;
|
||||
}
|
||||
return `This file is larger than the upload limit of ${formatFileSize(Number(info.metadata.limit ?? ""))}.`;
|
||||
}
|
||||
|
||||
function formatWait(seconds: number): string {
|
||||
if (seconds < 60) return `${seconds}s`;
|
||||
const minutes = Math.ceil(seconds / 60);
|
||||
@@ -141,7 +123,7 @@ export function getErrorMessage(error: unknown, fallback = "Unknown error"): str
|
||||
if (hasErrorReason(error, ERROR_REASON_CHALLENGE_REQUIRED)) {
|
||||
return "Complete the verification challenge and try again.";
|
||||
}
|
||||
const limitMessage = getLimitErrorMessage(error);
|
||||
const limitMessage = getQuotaExceededMessage(error);
|
||||
if (limitMessage !== undefined) {
|
||||
return limitMessage;
|
||||
}
|
||||
|
||||
@@ -496,8 +496,6 @@
|
||||
"title": "تخصيص الخادم"
|
||||
},
|
||||
"enable-double-click-to-edit": "تمكين النقر المزدوج للتحرير",
|
||||
"max-upload-size": "الحد الأقصى لحجم الرفع (ميغابايت)",
|
||||
"max-upload-size-hint": "القيمة الموصى بها هي 32 ميغابايت.",
|
||||
"server-name": "اسم الخادم",
|
||||
"label": "النظام",
|
||||
"additional-script-description": "إضافة جافا سكريبت إلى جميع صفحات الويب. استخدام التعليمات البرمجية الموثوقة فقط.",
|
||||
@@ -607,7 +605,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -908,8 +908,6 @@
|
||||
"custom-code-title": "Xüsusi kod",
|
||||
"enable-double-click-to-edit": "Redaktə üçün ikiqat kliki aktivləşdir",
|
||||
"label": "Sistem",
|
||||
"max-upload-size": "Maksimum yükləmə ölçüsü (MiB)",
|
||||
"max-upload-size-hint": "Tövsiyə olunan dəyər 32 MiB-dir.",
|
||||
"server-name": "Server adı"
|
||||
},
|
||||
"usage-limits": {
|
||||
@@ -922,7 +920,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -714,8 +714,6 @@
|
||||
"custom-code-title": "Персонализиран код",
|
||||
"enable-double-click-to-edit": "Активирайте двойното щракване за редактиране",
|
||||
"label": "система",
|
||||
"max-upload-size": "Максимален размер за качване (MiB)",
|
||||
"max-upload-size-hint": "Препоръчителната стойност е 32 MiB.",
|
||||
"server-name": "Име на сървъра"
|
||||
},
|
||||
"usage-limits": {
|
||||
@@ -728,7 +726,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -593,8 +593,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "Habilita doble clic per editar",
|
||||
"label": "Sistema",
|
||||
"max-upload-size": "Mida màxima de pujada (MiB)",
|
||||
"max-upload-size-hint": "El valor recomanat és 32 MiB.",
|
||||
"server-name": "Nom del servidor",
|
||||
"additional-script-description": "Injecteu JavaScript a cada pàgina web. Utilitzeu només codi de confiança.",
|
||||
"additional-style-description": "Injecteu CSS a l'aplicació web per ajustar la presentació a tota la instància.",
|
||||
@@ -612,7 +610,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -593,8 +593,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "Povolit dvojklik pro editaci",
|
||||
"label": "Systém",
|
||||
"max-upload-size": "Maximální velikost nahrávaného souboru (MiB)",
|
||||
"max-upload-size-hint": "Doporučená hodnota je 32 MiB.",
|
||||
"server-name": "Název serveru",
|
||||
"additional-script-description": "Vložte JavaScript do každé webové stránky. Používejte pouze důvěryhodný kód.",
|
||||
"additional-style-description": "Vložením CSS do webové aplikace upravíte prezentaci v rámci celé instance.",
|
||||
@@ -612,7 +610,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -714,8 +714,6 @@
|
||||
"custom-code-title": "Brugerdefineret kode",
|
||||
"enable-double-click-to-edit": "Aktiver dobbeltklik for at redigere",
|
||||
"label": "System",
|
||||
"max-upload-size": "Maksimal uploadstørrelse (MiB)",
|
||||
"max-upload-size-hint": "Den anbefalede værdi er 32 MiB.",
|
||||
"server-name": "Servernavn"
|
||||
},
|
||||
"usage-limits": {
|
||||
@@ -728,7 +726,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -593,8 +593,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "Doppelklick zum Bearbeiten aktivieren",
|
||||
"label": "System",
|
||||
"max-upload-size": "Maximale Uploadgröße (MiB)",
|
||||
"max-upload-size-hint": "Empfohlener Wert ist 32 MiB.",
|
||||
"server-name": "Servername",
|
||||
"additional-script-description": "Fügen Sie JavaScript in jede Webseite ein. Verwenden Sie nur vertrauenswürdigen Code.",
|
||||
"additional-style-description": "Fügen Sie CSS in die Web-App ein, um die instanzweite Darstellung anzupassen.",
|
||||
@@ -612,7 +610,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -714,8 +714,6 @@
|
||||
"custom-code-title": "Προσαρμοσμένος κωδικός",
|
||||
"enable-double-click-to-edit": "Ενεργοποιήστε το διπλό κλικ για επεξεργασία",
|
||||
"label": "Σύστημα",
|
||||
"max-upload-size": "Μέγιστο μέγεθος μεταφόρτωσης (MiB)",
|
||||
"max-upload-size-hint": "Η συνιστώμενη τιμή είναι 32 MiB.",
|
||||
"server-name": "Όνομα διακομιστή"
|
||||
},
|
||||
"usage-limits": {
|
||||
@@ -728,7 +726,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -593,8 +593,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "Enable double click to edit",
|
||||
"label": "System",
|
||||
"max-upload-size": "Maximum upload size (MiB)",
|
||||
"max-upload-size-hint": "Recommended value is 32 MiB.",
|
||||
"server-name": "Server Name",
|
||||
"additional-script-description": "Inject JavaScript into every web page. Use only trusted code.",
|
||||
"additional-style-description": "Inject CSS into the web app to adjust instance-wide presentation.",
|
||||
@@ -612,7 +610,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -908,8 +908,6 @@
|
||||
"custom-code-title": "Custom code",
|
||||
"enable-double-click-to-edit": "Enable double click to edit",
|
||||
"label": "System",
|
||||
"max-upload-size": "Maximum upload size (MiB)",
|
||||
"max-upload-size-hint": "Recommended value is 32 MiB.",
|
||||
"server-name": "Server Name"
|
||||
},
|
||||
"usage-limits": {
|
||||
@@ -922,7 +920,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -593,8 +593,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "Habilitar doble clic para editar",
|
||||
"label": "Sistema",
|
||||
"max-upload-size": "Tamaño máximo de subida (MiB)",
|
||||
"max-upload-size-hint": "El valor recomendado es 32 MiB.",
|
||||
"server-name": "Nombre del servidor",
|
||||
"additional-script-description": "Inyecte JavaScript en cada página web. Utilice únicamente código confiable.",
|
||||
"additional-style-description": "Inyecte CSS en la aplicación web para ajustar la presentación de toda la instancia.",
|
||||
@@ -612,7 +610,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -714,8 +714,6 @@
|
||||
"custom-code-title": "Kohandatud kood",
|
||||
"enable-double-click-to-edit": "Redigeerimiseks lubage topeltklõps",
|
||||
"label": "Süsteem",
|
||||
"max-upload-size": "Maksimaalne üleslaadimise suurus (MiB)",
|
||||
"max-upload-size-hint": "Soovitatav väärtus on 32 MiB.",
|
||||
"server-name": "Serveri nimi"
|
||||
},
|
||||
"usage-limits": {
|
||||
@@ -728,7 +726,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -496,8 +496,6 @@
|
||||
"title": "سفارشیسازی سرور"
|
||||
},
|
||||
"enable-double-click-to-edit": "فعالسازی دوبار کلیک برای ویرایش",
|
||||
"max-upload-size": "حداکثر حجم بارگذاری (مگابایت)",
|
||||
"max-upload-size-hint": "مقدار پیشنهادی ۳۲ مگابایت است.",
|
||||
"server-name": "نام سرور",
|
||||
"label": "سیستم",
|
||||
"additional-script-description": "جاوا اسکریپت را به هر صفحه وب تزریق کنید. فقط از کد قابل اعتماد استفاده کنید.",
|
||||
@@ -607,7 +605,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -714,8 +714,6 @@
|
||||
"custom-code-title": "Mukautettu koodi",
|
||||
"enable-double-click-to-edit": "Ota muokkaus käyttöön kaksoisnapsauttamalla",
|
||||
"label": "Järjestelmä",
|
||||
"max-upload-size": "Suurin latauskoko (MiB)",
|
||||
"max-upload-size-hint": "Suositeltu arvo on 32 MiB.",
|
||||
"server-name": "Palvelimen nimi"
|
||||
},
|
||||
"usage-limits": {
|
||||
@@ -728,7 +726,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -593,8 +593,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "Activer le double-clic pour éditer",
|
||||
"label": "Système",
|
||||
"max-upload-size": "Taille maximale de téléversement (MiB)",
|
||||
"max-upload-size-hint": "La valeur recommandée est 32 MiB.",
|
||||
"server-name": "Nom du serveur",
|
||||
"additional-script-description": "Injectez JavaScript dans chaque page Web. Utilisez uniquement du code fiable.",
|
||||
"additional-style-description": "Injectez CSS dans l'application Web pour ajuster la présentation à l'échelle de l'instance.",
|
||||
@@ -612,7 +610,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -593,8 +593,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "Activar dobre pulsación para editar",
|
||||
"label": "Sistema",
|
||||
"max-upload-size": "Tamaño máximo de subida (MiB)",
|
||||
"max-upload-size-hint": "O valor recomendado é 32 MiB.",
|
||||
"server-name": "Nome do servidor",
|
||||
"additional-script-description": "Inxecta JavaScript en cada páxina web. Use só código de confianza.",
|
||||
"additional-style-description": "Inxecta CSS na aplicación web para axustar a presentación en toda a instancia.",
|
||||
@@ -612,7 +610,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -747,8 +747,6 @@
|
||||
"custom-code-title": "קוד מותאם אישית",
|
||||
"enable-double-click-to-edit": "אפשר לחיצה כפולה לעריכה",
|
||||
"label": "מערכת",
|
||||
"max-upload-size": "גודל העלאה מרבי (MiB)",
|
||||
"max-upload-size-hint": "הערך המומלץ הוא 32 MiB.",
|
||||
"server-name": "שם השרת"
|
||||
},
|
||||
"usage-limits": {
|
||||
@@ -761,7 +759,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -496,8 +496,6 @@
|
||||
"title": "सर्वर अनुकूलित करें"
|
||||
},
|
||||
"enable-double-click-to-edit": "डबल क्लिक से संपादन सक्षम करें",
|
||||
"max-upload-size": "अधिकतम अपलोड आकार (MiB)",
|
||||
"max-upload-size-hint": "अनुशंसित मान 32 MiB है।",
|
||||
"server-name": "सर्वर नाम",
|
||||
"label": "सिस्टम",
|
||||
"additional-script-description": "हर वेब पेज में JavaScript डालें। सिर्फ़ भरोसेमंद कोड का इस्तेमाल करें।",
|
||||
@@ -607,7 +605,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -593,8 +593,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "Omogući dvostruki klik za uređivanje",
|
||||
"label": "Sustav",
|
||||
"max-upload-size": "Maksimalna veličina prijenosa (MiB)",
|
||||
"max-upload-size-hint": "Preporučena vrijednost je 32 MiB.",
|
||||
"server-name": "Naziv servera",
|
||||
"additional-script-description": "Ubacite JavaScript u svaku web stranicu. Koristite samo pouzdani kod.",
|
||||
"additional-style-description": "Ubacite CSS u web-aplikaciju da prilagodite prezentaciju cijele instance.",
|
||||
@@ -612,7 +610,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -593,8 +593,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "Dupla kattintásos szerkesztés engedélyezése",
|
||||
"label": "Rendszer",
|
||||
"max-upload-size": "Maximális feltöltési méret (MiB)",
|
||||
"max-upload-size-hint": "Az ajánlott érték 32 MiB.",
|
||||
"server-name": "Szerver neve",
|
||||
"additional-script-description": "Szúrja be az JavaScript-et minden weboldalba. Csak megbízható kódot használjon.",
|
||||
"additional-style-description": "Szúrja be az CSS-et a webalkalmazásba a példányszintű megjelenítés beállításához.",
|
||||
@@ -612,7 +610,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -496,8 +496,6 @@
|
||||
"title": "Sesuaikan Server"
|
||||
},
|
||||
"enable-double-click-to-edit": "Aktifkan klik ganda untuk mengedit",
|
||||
"max-upload-size": "Ukuran unggah maksimum (MiB)",
|
||||
"max-upload-size-hint": "Nilai yang direkomendasikan adalah 32 MiB.",
|
||||
"server-name": "Nama Server",
|
||||
"label": "Sistem",
|
||||
"additional-script-description": "Suntikkan JavaScript ke setiap halaman web. Gunakan hanya kode tepercaya.",
|
||||
@@ -607,7 +605,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -593,8 +593,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "Abilita doppio click per modificare",
|
||||
"label": "Sistema",
|
||||
"max-upload-size": "Dimensione massima caricamento (MiB)",
|
||||
"max-upload-size-hint": "Valore consigliato di 32 MiB.",
|
||||
"server-name": "Nome server",
|
||||
"additional-script-description": "Inietta JavaScript in ogni pagina web. Utilizza solo codice attendibile.",
|
||||
"additional-style-description": "Inserisci CSS nell'app Web per regolare la presentazione a livello di istanza.",
|
||||
@@ -612,7 +610,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -593,8 +593,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "ダブルクリック編集を有効化",
|
||||
"label": "システム",
|
||||
"max-upload-size": "最大アップロードサイズ(MiB)",
|
||||
"max-upload-size-hint": "推奨値は32 MiBです。",
|
||||
"server-name": "サーバー名",
|
||||
"additional-script-description": "JavaScript をすべての Web ページに挿入します。 信頼できるコードのみを使用してください。",
|
||||
"additional-style-description": "CSS を Web アプリに挿入して、インスタンス全体のプレゼンテーションを調整します。",
|
||||
@@ -612,7 +610,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -593,8 +593,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "ორმაგი დაწკაპუნებით რედაქტირების ჩართვა",
|
||||
"label": "სისტემა",
|
||||
"max-upload-size": "მაქსიმალური ატვირთვის ზომა (MiB)",
|
||||
"max-upload-size-hint": "რეკომენდირებული ზომა არის 32 MiB.",
|
||||
"server-name": "სერვერის სახელი",
|
||||
"additional-script-description": "შეიტანეთ JavaScript ყველა ვებ გვერდზე. გამოიყენეთ მხოლოდ სანდო კოდი.",
|
||||
"additional-style-description": "შეიტანეთ CSS ვებ აპში, რათა დაარეგულიროთ პრეზენტაცია მაგალითზე.",
|
||||
@@ -612,7 +610,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -496,8 +496,6 @@
|
||||
"title": "서버 커스터마이징"
|
||||
},
|
||||
"enable-double-click-to-edit": "더블 클릭으로 편집 활성화",
|
||||
"max-upload-size": "최대 업로드 크기 (MiB)",
|
||||
"max-upload-size-hint": "권장값은 32 MiB입니다.",
|
||||
"server-name": "서버 이름",
|
||||
"label": "시스템",
|
||||
"additional-script-description": "모든 웹 페이지에 JavaScript를 삽입합니다. 신뢰할 수 있는 코드만 사용합니다.",
|
||||
@@ -607,7 +605,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -714,8 +714,6 @@
|
||||
"custom-code-title": "Pasirinktinis kodas",
|
||||
"enable-double-click-to-edit": "Įgalinkite dukart spustelėdami redaguoti",
|
||||
"label": "Sistema",
|
||||
"max-upload-size": "Maksimalus įkėlimo dydis (MiB)",
|
||||
"max-upload-size-hint": "Rekomenduojama vertė yra 32 MiB.",
|
||||
"server-name": "Serverio pavadinimas"
|
||||
},
|
||||
"usage-limits": {
|
||||
@@ -728,7 +726,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -714,8 +714,6 @@
|
||||
"custom-code-title": "Pielāgots kods",
|
||||
"enable-double-click-to-edit": "Iespējojiet dubultklikšķi, lai rediģētu",
|
||||
"label": "Sistēma",
|
||||
"max-upload-size": "Maksimālais augšupielādes lielums (MiB)",
|
||||
"max-upload-size-hint": "Ieteicamā vērtība ir 32 MiB.",
|
||||
"server-name": "Servera nosaukums"
|
||||
},
|
||||
"usage-limits": {
|
||||
@@ -728,7 +726,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -496,8 +496,6 @@
|
||||
"title": "सर्व्हर सानुकूलित करा"
|
||||
},
|
||||
"enable-double-click-to-edit": "डबल क्लिकने संपादन सक्षम करा",
|
||||
"max-upload-size": "कमाल अपलोड आकार (MiB)",
|
||||
"max-upload-size-hint": "शिफारस केलेले मूल्य 32 MiB आहे.",
|
||||
"server-name": "सर्व्हरचे नाव",
|
||||
"label": "प्रणाली",
|
||||
"additional-script-description": "प्रत्येक वेब पेजमध्ये जावास्क्रिप्ट इंजेक्ट करा. फक्त विश्वसनीय कोड वापरा.",
|
||||
@@ -607,7 +605,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -593,8 +593,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "Slå på dobbeltklikk for å redigere",
|
||||
"label": "System",
|
||||
"max-upload-size": "Maksimal opplastingsstørrelse (MiB)",
|
||||
"max-upload-size-hint": "Anbefalt verdi er 32 MiB.",
|
||||
"server-name": "Servernavn",
|
||||
"additional-script-description": "Injiser JavaScript på hver nettside. Bruk kun pålitelig kode.",
|
||||
"additional-style-description": "Injiser CSS i nettappen for å justere presentasjonen for hele forekomsten.",
|
||||
@@ -612,7 +610,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -593,8 +593,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "Dubbelklik om te bewerken inschakelen",
|
||||
"label": "Systeem",
|
||||
"max-upload-size": "Maximum uploadgrootte (MiB)",
|
||||
"max-upload-size-hint": "32 MiB wordt aangeraden.",
|
||||
"server-name": "Servernaam",
|
||||
"additional-script-description": "Injecteer JavaScript in elke webpagina. Gebruik alleen vertrouwde code.",
|
||||
"additional-style-description": "Injecteer CSS in de webapp om de presentatie voor de hele instantie aan te passen.",
|
||||
@@ -612,7 +610,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -926,8 +926,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "Slå på dobbeltklikk for redigering",
|
||||
"label": "System",
|
||||
"max-upload-size": "Største opplastingsstorleik (MiB)",
|
||||
"max-upload-size-hint": "Tilrådd verdi er 32 MiB.",
|
||||
"server-name": "Tenarnamn"
|
||||
},
|
||||
"tags": {
|
||||
@@ -957,7 +955,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -593,8 +593,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "Włącz edycję przez podwójne kliknięcie",
|
||||
"label": "System",
|
||||
"max-upload-size": "Maksymalny rozmiar przesyłanego pliku (MiB)",
|
||||
"max-upload-size-hint": "Zalecana wartość to 32 MiB.",
|
||||
"server-name": "Nazwa serwera",
|
||||
"additional-script-description": "Wstrzyknij JavaScript do każdej strony internetowej. Używaj tylko zaufanego kodu.",
|
||||
"additional-style-description": "Wstrzyknij CSS do aplikacji internetowej, aby dostosować prezentację w całej instancji.",
|
||||
@@ -612,7 +610,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -496,8 +496,6 @@
|
||||
"title": "Personalizar instância"
|
||||
},
|
||||
"enable-double-click-to-edit": "Ativar clique duplo para editar",
|
||||
"max-upload-size": "Tamanho máximo de upload (MiB)",
|
||||
"max-upload-size-hint": "O valor recomendado é 32 MiB.",
|
||||
"server-name": "Nome da instância",
|
||||
"label": "Sistema",
|
||||
"additional-script-description": "Injetar JavaScript em todas as páginas da web. Usar somente código confiável.",
|
||||
@@ -607,7 +605,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -593,8 +593,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "Ativar duplo clique para editar",
|
||||
"label": "Sistema",
|
||||
"max-upload-size": "Tamanho máximo de upload (MiB)",
|
||||
"max-upload-size-hint": "O valor recomendado é 32 MiB.",
|
||||
"server-name": "Nome do Servidor",
|
||||
"additional-script-description": "Injete JavaScript em todas as páginas da web. Use apenas código confiável.",
|
||||
"additional-style-description": "Injete CSS no aplicativo Web para ajustar a apresentação de toda a instância.",
|
||||
@@ -612,7 +610,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -714,8 +714,6 @@
|
||||
"custom-code-title": "Cod personalizat",
|
||||
"enable-double-click-to-edit": "Activați dublu clic pentru a edita",
|
||||
"label": "Sistem",
|
||||
"max-upload-size": "Dimensiunea maximă de încărcare (MiB)",
|
||||
"max-upload-size-hint": "Valoarea recomandată este 32 MiB.",
|
||||
"server-name": "Nume server"
|
||||
},
|
||||
"usage-limits": {
|
||||
@@ -728,7 +726,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -593,8 +593,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "Редактировать двойным кликом",
|
||||
"label": "Система",
|
||||
"max-upload-size": "Макс. размер файла (МБ)",
|
||||
"max-upload-size-hint": "Рекомендуемое значение 32 MБ",
|
||||
"server-name": "Имя сервера",
|
||||
"additional-script-description": "Внедрите JavaScript на каждую веб-страницу. Используйте только проверенный код.",
|
||||
"additional-style-description": "Внедрите CSS в веб-приложение, чтобы настроить представление всего экземпляра.",
|
||||
@@ -612,7 +610,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -714,8 +714,6 @@
|
||||
"custom-code-title": "Vlastný kód",
|
||||
"enable-double-click-to-edit": "Povoliť úpravy dvojitým kliknutím",
|
||||
"label": "Systém",
|
||||
"max-upload-size": "Maximálna veľkosť nahrávania (MiB)",
|
||||
"max-upload-size-hint": "Odporúčaná hodnota je 32 MiB.",
|
||||
"server-name": "Názov servera"
|
||||
},
|
||||
"usage-limits": {
|
||||
@@ -728,7 +726,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -593,8 +593,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "Omogoči dvojni klik za urejanje",
|
||||
"label": "Sistem",
|
||||
"max-upload-size": "Največja velikost nalaganja (MiB)",
|
||||
"max-upload-size-hint": "Priporočena velikost je 32 MiB.",
|
||||
"server-name": "Ime strežnika",
|
||||
"additional-script-description": "Vnesite JavaScript v vsako spletno stran. Uporabljajte samo zaupanja vredno kodo.",
|
||||
"additional-style-description": "Vnesite CSS v spletno aplikacijo, da prilagodite predstavitev celotne instance.",
|
||||
@@ -612,7 +610,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -714,8 +714,6 @@
|
||||
"custom-code-title": "Прилагођени код",
|
||||
"enable-double-click-to-edit": "Омогућите двоструки клик за уређивање",
|
||||
"label": "Систем",
|
||||
"max-upload-size": "Максимална величина отпремања (MiB)",
|
||||
"max-upload-size-hint": "Препоручена вредност је 32 MiB.",
|
||||
"server-name": "Име сервера"
|
||||
},
|
||||
"usage-limits": {
|
||||
@@ -728,7 +726,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -593,8 +593,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "Aktivera dubbelklick för att redigera",
|
||||
"label": "System",
|
||||
"max-upload-size": "Maximal uppladdningsstorlek (MiB)",
|
||||
"max-upload-size-hint": "Rekommenderat värde är 32 MiB.",
|
||||
"server-name": "Servernamn",
|
||||
"additional-script-description": "Injicera JavaScript i varje webbsida. Använd endast betrodd kod.",
|
||||
"additional-style-description": "Injicera CSS i webbappen för att justera instansomfattande presentation.",
|
||||
@@ -612,7 +610,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -496,8 +496,6 @@
|
||||
"title": "ปรับแต่งเซิร์ฟเวอร์"
|
||||
},
|
||||
"enable-double-click-to-edit": "เปิดใช้งานดับเบิลคลิกเพื่อแก้ไข",
|
||||
"max-upload-size": "ขนาดการอัปโหลดสูงสุด (MiB)",
|
||||
"max-upload-size-hint": "ค่าที่แนะนำคือ 32 MiB",
|
||||
"server-name": "ชื่อเซิร์ฟเวอร์",
|
||||
"label": "ระบบ",
|
||||
"additional-script-description": "แทรก JavaScript ลงในทุกหน้าเว็บ ใช้เฉพาะโค้ดที่เชื่อถือได้เท่านั้น",
|
||||
@@ -607,7 +605,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -754,8 +754,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "Düzenlemek için çift tıklamayı etkinleştir",
|
||||
"label": "Sistem",
|
||||
"max-upload-size": "Maksimum yükleme boyutu (MiB)",
|
||||
"max-upload-size-hint": "Önerilen değer 32 MiB'dir.",
|
||||
"server-name": "Sunucu Adı",
|
||||
"additional-script-description": "JavaScript'i her web sayfasına enjekte edin. Yalnızca güvenilir kodu kullanın.",
|
||||
"additional-style-description": "Örnek çapında sunumu ayarlamak için CSS'i web uygulamasına enjekte edin.",
|
||||
@@ -773,7 +771,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -593,8 +593,6 @@
|
||||
},
|
||||
"enable-double-click-to-edit": "Увімкнути двократне натискання для редагування",
|
||||
"label": "Система",
|
||||
"max-upload-size": "Максимальний розмір завантаження (MiB)",
|
||||
"max-upload-size-hint": "Рекомендується значення - 32 MiB.",
|
||||
"server-name": "Назва сервера",
|
||||
"additional-script-description": "Вставте JavaScript на кожну веб-сторінку. Використовуйте лише надійний код.",
|
||||
"additional-style-description": "Вставте CSS у веб-програму, щоб налаштувати презентацію для всього екземпляра.",
|
||||
@@ -612,7 +610,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -496,8 +496,6 @@
|
||||
"title": "Tùy chỉnh máy chủ"
|
||||
},
|
||||
"enable-double-click-to-edit": "Bật nhấp đúp để chỉnh sửa",
|
||||
"max-upload-size": "Kích thước tải lên tối đa (MiB)",
|
||||
"max-upload-size-hint": "Giá trị đề xuất là 32 MiB.",
|
||||
"server-name": "Tên máy chủ",
|
||||
"label": "Hệ thống",
|
||||
"additional-script-description": "Chèn JavaScript vào mọi trang web. Chỉ sử dụng mã đáng tin cậy.",
|
||||
@@ -607,7 +605,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -575,8 +575,6 @@
|
||||
"custom-code-description": "应用到前端的实例范围 CSS 和 JavaScript,可选。",
|
||||
"custom-code-title": "自定义代码",
|
||||
"enable-double-click-to-edit": "启用双击编辑",
|
||||
"max-upload-size": "最大上传大小 (MiB)",
|
||||
"max-upload-size-hint": "建议值为 32 MiB。",
|
||||
"server-name": "服务器名称",
|
||||
"label": "系统"
|
||||
},
|
||||
@@ -681,7 +679,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
@@ -836,8 +836,6 @@
|
||||
"custom-code-title": "自訂代碼",
|
||||
"enable-double-click-to-edit": "啟用雙擊編輯",
|
||||
"label": "系統",
|
||||
"max-upload-size": "最大上傳檔案大小 (MiB)",
|
||||
"max-upload-size-hint": "建議值為 32 MiB。",
|
||||
"server-name": "伺服器名稱"
|
||||
},
|
||||
"usage-limits": {
|
||||
@@ -850,7 +848,6 @@
|
||||
"description": "Keep this instance fast and reliable by capping what each user can store. All users applies to everyone, and a user's own limits replace it. Gray values come from All users.",
|
||||
"file-size": "Largest file (MiB)",
|
||||
"file-size-column": "Largest file",
|
||||
"file-size-warning": "Not below the instance upload limit of {{limit}} MiB, so it has no effect.",
|
||||
"invalid": "Enter a whole number of memos, or a size in MiB.",
|
||||
"label": "Usage limits",
|
||||
"memos": "Memos",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -996,8 +996,7 @@ export type UserUsage = Message<"memos.api.UserUsage"> & {
|
||||
storageBytesLimit?: UserUsage_EffectiveLimit | undefined;
|
||||
|
||||
/**
|
||||
* The limit on the size of one uploaded file. It applies only when it is
|
||||
* lower than the instance upload limit.
|
||||
* The limit on the size of one uploaded file.
|
||||
*
|
||||
* @generated from field: memos.api.UserUsage.EffectiveLimit upload_bytes_limit = 6;
|
||||
*/
|
||||
@@ -1019,7 +1018,7 @@ export const UserUsageSchema: GenMessage<UserUsage> = /*@__PURE__*/
|
||||
*/
|
||||
export type UserUsage_EffectiveLimit = Message<"memos.api.UserUsage.EffectiveLimit"> & {
|
||||
/**
|
||||
* The limit. 0 means unlimited, or no extra limit for upload_bytes_limit.
|
||||
* The limit. 0 means unlimited.
|
||||
*
|
||||
* @generated from field: int64 value = 1;
|
||||
*/
|
||||
|
||||
@@ -2,11 +2,11 @@ import { BinaryWriter } from "@bufbuild/protobuf/wire";
|
||||
import { Code, ConnectError } from "@connectrpc/connect";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { errorService } from "@/components/MemoEditor/services/errorService";
|
||||
import { ERROR_REASON_FILE_TOO_LARGE, ERROR_REASON_QUOTA_EXCEEDED, getErrorMessage, getRetryAfterSeconds } from "@/lib/error";
|
||||
import { ERROR_REASON_QUOTA_EXCEEDED, getErrorMessage, getRetryAfterSeconds } from "@/lib/error";
|
||||
|
||||
function quotaError(metadata: Record<string, string>, reason = ERROR_REASON_QUOTA_EXCEEDED): ConnectError {
|
||||
function quotaError(metadata: Record<string, string>): ConnectError {
|
||||
const writer = new BinaryWriter();
|
||||
writer.tag(1, 2).string(reason);
|
||||
writer.tag(1, 2).string(ERROR_REASON_QUOTA_EXCEEDED);
|
||||
writer.tag(2, 2).string("memos.api");
|
||||
for (const [key, value] of Object.entries(metadata)) {
|
||||
const entry = new BinaryWriter();
|
||||
@@ -40,12 +40,6 @@ describe("usage limit refusals", () => {
|
||||
expect(getRetryAfterSeconds(error)).toBeUndefined();
|
||||
});
|
||||
|
||||
it("names the instance upload limit", () => {
|
||||
const error = quotaError({ limit: String(32 * 1024 ** 2), size: String(40 * 1024 ** 2) }, ERROR_REASON_FILE_TOO_LARGE);
|
||||
expect(getErrorMessage(error)).toBe("This file is larger than the upload limit of 32.0 MB.");
|
||||
expect(errorService.getErrorMessage(error)).toBe("This file is larger than the upload limit of 32.0 MB.");
|
||||
});
|
||||
|
||||
it("reaches the editor's own error messages", () => {
|
||||
const error = quotaError({ metric: "UPLOAD_BYTES", limit: String(1024 ** 2), usage: String(2 * 1024 ** 2) });
|
||||
expect(errorService.getErrorMessage(error)).toBe("This file is larger than your limit of 1.0 MB per file.");
|
||||
|
||||
@@ -19,7 +19,6 @@ const mocks = vi.hoisted(() => ({
|
||||
createUsageLimit: vi.fn(),
|
||||
updateUsageLimit: vi.fn(),
|
||||
deleteUsageLimit: vi.fn(),
|
||||
getInstanceSetting: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("@/connect", () => ({
|
||||
@@ -29,7 +28,6 @@ vi.mock("@/connect", () => ({
|
||||
createUsageLimit: mocks.createUsageLimit,
|
||||
updateUsageLimit: mocks.updateUsageLimit,
|
||||
deleteUsageLimit: mocks.deleteUsageLimit,
|
||||
getInstanceSetting: mocks.getInstanceSetting,
|
||||
},
|
||||
}));
|
||||
vi.mock("@/hooks/useCurrentUser", () => ({ default: () => ({ name: "users/alice" }) }));
|
||||
@@ -59,7 +57,6 @@ const effective = (value: bigint, usageLimit = "") => create(UserUsage_Effective
|
||||
|
||||
beforeEach(() => {
|
||||
for (const mock of Object.values(mocks)) mock.mockReset();
|
||||
mocks.getInstanceSetting.mockResolvedValue({ value: { case: "storageSetting", value: { uploadSizeLimitMb: 30n } } });
|
||||
mocks.createUsageLimit.mockResolvedValue({});
|
||||
mocks.updateUsageLimit.mockResolvedValue({});
|
||||
mocks.deleteUsageLimit.mockResolvedValue({});
|
||||
@@ -174,7 +171,7 @@ describe("UsageLimitDialog", () => {
|
||||
],
|
||||
nextPageToken: "",
|
||||
});
|
||||
render(<UsageLimitDialog open onOpenChange={vi.fn()} target={{ kind: "all" }} candidates={[]} uploadLimitMiB={32} />, { wrapper });
|
||||
render(<UsageLimitDialog open onOpenChange={vi.fn()} target={{ kind: "all" }} candidates={[]} />, { wrapper });
|
||||
|
||||
expect(await screen.findByText("Limits for all users")).toBeInTheDocument();
|
||||
const memos = screen.getByRole("textbox", { name: "Memos" });
|
||||
@@ -206,7 +203,7 @@ describe("UsageLimitDialog", () => {
|
||||
],
|
||||
nextPageToken: "",
|
||||
});
|
||||
render(<UsageLimitDialog open onOpenChange={vi.fn()} target={{ kind: "user", user: bob }} candidates={[]} uploadLimitMiB={32} />, {
|
||||
render(<UsageLimitDialog open onOpenChange={vi.fn()} target={{ kind: "user", user: bob }} candidates={[]} />, {
|
||||
wrapper,
|
||||
});
|
||||
|
||||
@@ -232,7 +229,7 @@ describe("UsageLimitDialog", () => {
|
||||
|
||||
it("adds limits for a picked user", async () => {
|
||||
mocks.listUsageLimits.mockResolvedValue({ usageLimits: [], nextPageToken: "" });
|
||||
render(<UsageLimitDialog open onOpenChange={vi.fn()} target={{ kind: "add" }} candidates={[carol]} uploadLimitMiB={32} />, { wrapper });
|
||||
render(<UsageLimitDialog open onOpenChange={vi.fn()} target={{ kind: "add" }} candidates={[carol]} />, { wrapper });
|
||||
|
||||
expect(await screen.findByRole("heading", { name: "Add user limit" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "Save" })).toBeDisabled();
|
||||
@@ -240,8 +237,6 @@ describe("UsageLimitDialog", () => {
|
||||
await chooseOption("User", "@carol");
|
||||
const fileSize = screen.getByRole("textbox", { name: "Largest file (MiB)" });
|
||||
await waitFor(() => expect(fileSize).toBeEnabled());
|
||||
fireEvent.change(fileSize, { target: { value: "32" } });
|
||||
expect(await screen.findByText("Not below the instance upload limit of 32 MiB, so it has no effect.")).toBeInTheDocument();
|
||||
fireEvent.change(fileSize, { target: { value: "10" } });
|
||||
fireEvent.click(screen.getByRole("button", { name: "Save" }));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user