Skip to content
This repository was archived by the owner on Oct 19, 2026. It is now read-only.

Commit 5fed496

Browse files
authored
chore: remove some config about split chunk (#1778)
* chore: remove some config about split chunk * chore/remove related config in common * chore/remove storage_type_enum * fix:PostgreSQL-only migration
1 parent 53effd3 commit 5fed496

10 files changed

Lines changed: 106 additions & 71 deletions

File tree

‎ceres/src/lfs/handler.rs‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,14 @@ pub async fn lfs_process_batch(
183183
let mut response_objects = Vec::new();
184184
let file_storage = storage.lfs_file_storage();
185185
let db_storage = storage.lfs_db_storage();
186-
let config = storage.config().lfs.clone();
187186
for object in objects {
188187
let meta_res = lfs_get_meta(db_storage.clone(), &object.oid).await.unwrap();
189188
let meta = match meta_res {
190189
Some(meta) => meta,
191190
None => {
192191
if request.operation == Operation::Upload {
193192
// Save to database if not exist.
194-
let meta = MetaObject::new(&object, &config);
193+
let meta = MetaObject::new(&object);
195194
db_storage
196195
.new_lfs_object(meta.clone().into())
197196
.await
@@ -519,7 +518,6 @@ mod tests {
519518
oid: "oid1".into(),
520519
size: 10,
521520
exist: true,
522-
splited: false,
523521
};
524522
let res = ResponseObject::new(
525523
&meta,
@@ -543,7 +541,6 @@ mod tests {
543541
oid: "oid2".into(),
544542
size: 20,
545543
exist: false,
546-
splited: false,
547544
};
548545
let res = ResponseObject::new(
549546
&meta,
@@ -566,7 +563,6 @@ mod tests {
566563
oid: "oid3".into(),
567564
size: 30,
568565
exist: false,
569-
splited: false,
570566
};
571567
let res = ResponseObject::new(
572568
&meta,

‎ceres/src/lfs/lfs_structs.rs‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use callisto::lfs_objects;
2-
use callisto::sea_orm_active_enums::StorageTypeEnum;
32
use chrono::{DateTime, Duration, Utc};
4-
use common::config::LFSConfig;
53
use serde::{Deserialize, Serialize};
64
use std::collections::HashMap;
75
use utoipa::ToSchema;
@@ -44,7 +42,6 @@ pub struct MetaObject {
4442
pub oid: String,
4543
pub size: i64,
4644
pub exist: bool,
47-
pub splited: bool,
4845
}
4946

5047
impl From<lfs_objects::Model> for MetaObject {
@@ -53,7 +50,6 @@ impl From<lfs_objects::Model> for MetaObject {
5350
oid: value.oid,
5451
size: value.size,
5552
exist: value.exist,
56-
splited: value.splited,
5753
}
5854
}
5955
}
@@ -64,23 +60,16 @@ impl From<MetaObject> for lfs_objects::Model {
6460
oid: value.oid,
6561
size: value.size,
6662
exist: value.exist,
67-
splited: value.splited,
6863
}
6964
}
7065
}
7166

7267
impl MetaObject {
73-
pub fn new(req_obj: &RequestObject, config: &LFSConfig) -> Self {
74-
let splited = config.local.enable_split;
68+
pub fn new(req_obj: &RequestObject) -> Self {
7569
Self {
7670
oid: req_obj.oid.to_string(),
7771
size: req_obj.size,
7872
exist: true,
79-
splited: if StorageTypeEnum::AwsS3 == config.storage_type.clone().into() {
80-
false
81-
} else {
82-
splited
83-
},
8473
}
8574
}
8675
}

‎common/src/config.rs‎

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ use config::builder::DefaultState;
1313
use config::{Source, ValueKind};
1414
use serde::{Deserialize, Deserializer, Serialize};
1515

16-
use callisto::sea_orm_active_enums::StorageTypeEnum;
17-
1816
use crate::utils;
1917

2018
/// Retrieves the base directory path for Mega
@@ -531,26 +529,6 @@ pub enum StorageType {
531529
S3,
532530
}
533531

534-
impl From<StorageTypeEnum> for StorageType {
535-
fn from(value: StorageTypeEnum) -> Self {
536-
match value {
537-
StorageTypeEnum::Database => StorageType::Database,
538-
StorageTypeEnum::LocalFs => StorageType::LocalFs,
539-
StorageTypeEnum::AwsS3 => StorageType::S3,
540-
}
541-
}
542-
}
543-
544-
impl From<StorageType> for StorageTypeEnum {
545-
fn from(value: StorageType) -> Self {
546-
match value {
547-
StorageType::Database => StorageTypeEnum::Database,
548-
StorageType::LocalFs => StorageTypeEnum::LocalFs,
549-
StorageType::S3 => StorageTypeEnum::AwsS3,
550-
}
551-
}
552-
}
553-
554532
impl Default for LFSConfig {
555533
fn default() -> Self {
556534
Self {
@@ -564,17 +542,12 @@ impl Default for LFSConfig {
564542
#[derive(Serialize, Deserialize, Debug, Clone)]
565543
pub struct LFSLocalConfig {
566544
pub lfs_file_path: PathBuf,
567-
pub enable_split: bool,
568-
#[serde(deserialize_with = "string_or_usize")]
569-
pub split_size: String,
570545
}
571546

572547
impl Default for LFSLocalConfig {
573548
fn default() -> Self {
574549
Self {
575550
lfs_file_path: mega_base().join("lfs"),
576-
enable_split: true,
577-
split_size: "20M".to_string(),
578551
}
579552
}
580553
}

‎config/config-workflow.toml‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,6 @@ http_url = "http://localhost:8000"
110110
# set the local path of the lfs storage
111111
lfs_file_path = "${base_dir}/lfs"
112112

113-
## IMPORTANT: The 'enable_split' feature can only be enabled for new databases. Existing databases do not support this feature.
114-
# Enable or disable splitting large files into smaller chunks
115-
enable_split = true # Default is disabled. Set to true to enable file splitting.
116-
117-
# Size of each file chunk when splitting is enabled. Ignored if splitting is disabled.
118-
split_size = "20M"
119-
120113
[lfs.aws]
121114
s3_bucket = "gitmono"
122115
s3_region = "ap-southeast-2"
@@ -138,4 +131,8 @@ cookie_domain = "localhost"
138131
campsite_api_domain = "http://api.gitmega.com"
139132

140133
# allowed cors origins
141-
allowed_cors_origins = ["http://local.gitmega.com", "https://app.gitmega.com", "http://app.gitmono.test"]
134+
allowed_cors_origins = [
135+
"http://local.gitmega.com",
136+
"https://app.gitmega.com",
137+
"http://app.gitmono.test",
138+
]

‎config/config.toml‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,6 @@ http_url = "http://localhost:8000"
114114
# set the local path of the lfs storage
115115
lfs_file_path = "${base_dir}/lfs"
116116

117-
## IMPORTANT: The 'enable_split' feature can only be enabled for new databases. Existing databases do not support this feature.
118-
# Enable or disable splitting large files into smaller chunks
119-
enable_split = true # Default is disabled. Set to true to enable file splitting.
120-
121-
# Size of each file chunk when splitting is enabled. Ignored if splitting is disabled.
122-
split_size = "20M"
123-
124-
125117
[s3]
126118
# AWS region name.
127119
# For AWS S3 this must match the bucket's region.

‎jupiter/callisto/src/lfs_objects.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pub struct Model {
1010
pub oid: String,
1111
pub size: i64,
1212
pub exist: bool,
13-
pub splited: bool,
1413
}
1514

1615
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

‎jupiter/callisto/src/sea_orm_active_enums.rs‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,3 @@ pub enum ReferenceTypeEnum {
123123
#[sea_orm(string_value = "blocks")]
124124
Blocks,
125125
}
126-
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
127-
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "storage_type_enum")]
128-
pub enum StorageTypeEnum {
129-
#[sea_orm(string_value = "database")]
130-
Database,
131-
#[sea_orm(string_value = "local_fs")]
132-
LocalFs,
133-
#[sea_orm(string_value = "aws_s3")]
134-
AwsS3,
135-
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
use sea_orm_migration::prelude::*;
2+
3+
#[derive(DeriveMigrationName)]
4+
pub struct Migration;
5+
6+
#[async_trait::async_trait]
7+
impl MigrationTrait for Migration {
8+
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
9+
manager
10+
.alter_table(
11+
Table::alter()
12+
.table(LfsObjects::Table)
13+
.drop_column(LfsObjects::Splited)
14+
.to_owned(),
15+
)
16+
.await
17+
}
18+
19+
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
20+
manager
21+
.alter_table(
22+
Table::alter()
23+
.table(LfsObjects::Table)
24+
.add_column(
25+
ColumnDef::new(LfsObjects::Splited)
26+
.boolean()
27+
.not_null()
28+
.default(false),
29+
)
30+
.to_owned(),
31+
)
32+
.await
33+
}
34+
}
35+
36+
#[derive(Iden)]
37+
enum LfsObjects {
38+
Table,
39+
Splited,
40+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
use sea_orm_migration::{
2+
prelude::*,
3+
sea_orm::{DatabaseBackend, Statement},
4+
};
5+
6+
#[derive(DeriveMigrationName)]
7+
pub struct Migration;
8+
9+
#[async_trait::async_trait]
10+
impl MigrationTrait for Migration {
11+
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
12+
let backend = manager.get_database_backend();
13+
14+
match backend {
15+
DatabaseBackend::Postgres => {
16+
manager
17+
.get_connection()
18+
.execute(Statement::from_string(
19+
DatabaseBackend::Postgres,
20+
"DROP TYPE IF EXISTS storage_type_enum;".to_owned(),
21+
))
22+
.await?;
23+
}
24+
DatabaseBackend::Sqlite | DatabaseBackend::MySql => {}
25+
}
26+
27+
Ok(())
28+
}
29+
30+
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
31+
let backend = manager.get_database_backend();
32+
33+
match backend {
34+
DatabaseBackend::Postgres => {
35+
manager
36+
.get_connection()
37+
.execute(Statement::from_string(
38+
DatabaseBackend::Postgres,
39+
r#"
40+
CREATE TYPE storage_type_enum AS ENUM (
41+
'database',
42+
'local_fs',
43+
'aws_s3'
44+
);
45+
"#
46+
.to_owned(),
47+
))
48+
.await?;
49+
}
50+
DatabaseBackend::Sqlite | DatabaseBackend::MySql => {}
51+
}
52+
53+
Ok(())
54+
}
55+
}

‎jupiter/src/migration/mod.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ mod m20251203_013745_add_dynamic_sidebar;
7676
mod m20251210_113942_remove_unique_constraint_from_order_index;
7777
mod m20260106_070511_add_retry_time;
7878
mod m20260106_070515_remove_relay_mq_lfs_raw_table;
79+
mod m20260108_085945_remove_splited_in_lfs_objects;
80+
mod m20260108_105158_remove_storage_type_enum;
7981

8082
/// Creates a primary key column definition with big integer type.
8183
///
@@ -140,6 +142,8 @@ impl MigratorTrait for Migrator {
140142
Box::new(m20251210_113942_remove_unique_constraint_from_order_index::Migration),
141143
Box::new(m20260106_070511_add_retry_time::Migration),
142144
Box::new(m20260106_070515_remove_relay_mq_lfs_raw_table::Migration),
145+
Box::new(m20260108_085945_remove_splited_in_lfs_objects::Migration),
146+
Box::new(m20260108_105158_remove_storage_type_enum::Migration),
143147
]
144148
}
145149
}

0 commit comments

Comments
 (0)