Skip to content

Commit 86ffd90

Browse files
author
Fastace
committed
feat(cloud): 新增华为云 OBS 云存储后端并统一新增账户与发布行为
与既有 S3(腾讯云 COS)/AWSS3/ALIYUNOSS 链路同构,新增 CloudType.HUAWEIOBS 云类型,打通 「添加账户 → 目录浏览 → restic 仓库备份/恢复」全流程。目录浏览与 rustic 仓库访问统一走 opendal 的 obs scheme;同时收敛一批一致性问题:新增账户不再回填历史 restic 初始化密码、 去掉不适用于移动端的 VPC/内网 endpoint 说明、修复英文下增量胶囊把数值挤成省略号, 以及 JNI 工作流的 Version Name 与 Release Type 联动。 一、数据模型(core/model) - CloudType 新增 HUAWEIOBS("Huawei Cloud OBS") - 新增 HuaweiObsExtra:accessKeyId / secretAccessKey / bucket / endpoint / protocol / resticPassword,配套新增 HuaweiObsProtocol(HTTP, HTTPS)。华为云没有独立 region 配置, 地域由 endpoint 表达;密钥字段名沿用华为云官方命名 secretAccessKey,与 OSS 的 accessKeySecret 区分 - CloudEntity 沿用既有承载方式:host=bucket、user=AccessKeyId、pass=SecretAccessKey, 完整配置以 extra 保存 二、网络层(core/network) - 新增 HuaweiObsClientImpl,实现 CloudClient,scheme 为 "obs" - buildOpendalOptions() 产出 bucket/root/endpoint/access_key_id/secret_access_key 五键, 与 rustic 仓库侧使用同一套键,避免两处语义漂移 - buildOpendalEndpoint() 一律剥离 http(s):// 前缀:opendal 的 OBS builder 会自行拼 https://{bucket}.{endpoint},带 scheme 下发会拼出非法节点(与 OSS 的"按所选协议补全" 行为相反);protocol 字段仅参与界面完整地址预览 - 列目录/建目录经 RemoteRootService.opendalList / opendalCreateDir;testConnection 以 成功列举根路径为连通判据 三、restic 仓库层(core/restic) - 新增 ResticRepositoryHuaweiObs:backendUrl 为 opendal:obs,root 走 shared.formatOpenDALRoot(remotePath),其余四键与目录浏览一致 - CloudResticBackendModule 新增 @BINDS @Intomap @CloudTypeKey(CloudType.HUAWEIOBS) 绑定,注册方式与 AWSS3/COS/OSS 相同 - BackupServiceCloudImpl 的 restic 备份分支加入 CloudType.HUAWEIOBS 四、UI / 路由 / 文案 - Routes 新增 MainRoutes.HuaweiObsSetup;MainActivity 的 NavHost 注册 PageHuaweiObsSetup;云列表跳转与「添加账户」入口按 HUAWEIOBS 分发 - ModelUtil 为 CloudType.HUAWEIOBS 指定 Storage 图标 - 新增 HuaweiObsSetup 引导页:Access Key Id(AK) / Secret Access Key(SK) / Bucket / Endpoint(含填写说明与完整访问地址预览)/ 协议分段按钮 / 仓库路径与密码 / 连接测试 / 仓库初始化,配套新增 HuaweiObsResticViewModel - IndexViewModel 新增 buildHuaweiObsCloudEntity 与 updateHuaweiObsEntity - feature:main:cloud 的 values 与 values-zh-rCN 同步补齐双语文案: cloud_type_huawei_obs / huawei_obs_setup / huawei_obs_access_key_id / huawei_obs_access_key_secret / huawei_obs_endpoint / huawei_obs_endpoint_example / huawei_obs_url_preview 五、新增账户不再回填历史 restic 初始化密码(fix) - AliyunOssResticViewModel / HuaweiObsResticViewModel 删除 init 中读取全局 datastore (readXxxResticPassword / readXxxResticInitialized / readXxxResticRepoPath)并预填 密码框、直接置 Success 的逻辑 - 两者此前会把密码 StateFlow 回写输入框,导致新增账户一进来就带着上一个账户的初始化 密码,与 AWS S3 / COS 表现不一致;删除后新增一律为空 + Idle 状态,必须重新输入并初始化 - 编辑既有账户仍由 restoreStateFromEntity() 从 CloudEntity.extra.resticPassword 恢复, 老账户无需重输;initialize 成功时的 save* 保留,供 restic 侧 resolveResticPassword 兜底 六、文案与可读性问题修复 - aliyun_oss_endpoint_example / huawei_obs_endpoint_example(en + zh)删除 ECS 的 VPC/内网地址相关说明——移动端不走内网,保留反而误导填写 - core/ui 的 increment 英文由 Incremental(11 字符) 改为 Added(5):语义仍是去重后 实际新增写入的数据量,并与 Total/Speed/Dedup 三个胶囊宽度对齐 - core/ui Card.kt 的 ProgressStatChip 给标签加 Modifier.weight(1f, fill = false): 空间不足时先牺牲标签自身省略,右侧数值永远完整显示,不再出现被截断的大小 七、偏好存储(core/datastore)与 native - 新增 huawei_obs_restic_repo_path / huawei_obs_restic_password / huawei_obs_restic_initialized 三个键及其 save/read 扩展函数,与既有云类型保持一致 - source/native/.../rustic/rustic/Cargo.toml 的 opendal features 追加 services-obs (目录浏览所需;与 rustic_backend 复用同一 opendal 版本以合并特性) 八、文档 - README.md 与 README_en.md 的云存储协议支持表:Aliyun OSS / HuaWei OBS 由 「待实现 / WIP」改为「已完成 / done」,并删除表格下方"逐步适配中,敬请期待"的引用块 九、CI:JNI 构建脚本 Version Name 与 Release Type 联动 - .github/workflows/build-jni.yaml 的 job env 新增 BASE_VERSION_NAME: '3.0.1-Rustic-JNI' - Calculate Dynamic Version 改为"手动值优先 + 按 release_type 兜底":version_name 留空时 release → 3.0.1-Rustic-JNI、pre-release → 3.0.1-Rustic-JNI-Pre;输入框带 trim,避免 误填空格被判定为手动值 - 不再 grep gradle/libs.versions.toml 兜底(该值为本地用的 3.0.1-Rustic-JNI-Local, 不适合作为发布版本名);构建注入与 tag 链路沿用既有输出,未改动 验证 - :feature:main:cloud、:core:service、:core:restic、:core:network、:core:ui、 :feature:main:processing 的 compileDebugKotlin 与 :feature:main:cloud 的 processDebugResources 全部 BUILD SUCCESSFUL - :app:compileArm64-v8aFossDebugKotlin 通过,含 app 级 Hilt/KSP 全图校验 - .github/workflows/build-jni.yaml 改动仅涉及输入描述、job env 与 shell 判定块, 未改动既有 task/tag 表达式
1 parent 4c49b22 commit 86ffd90

25 files changed

Lines changed: 1212 additions & 33 deletions

File tree

‎.github/workflows/build-jni.yaml‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ on:
2828
- release
2929
default: 'pre-release'
3030
version_name:
31-
description: 'Version Name (e.g., 3.0.1-S3)'
31+
description: 'Version Name (留空自动联动 Release Type:release → 3.0.1-Rustic-JNI,pre-release → 3.0.1-Rustic-JNI-Pre)'
3232
required: false
3333
default: ''
3434

@@ -40,6 +40,8 @@ jobs:
4040
contents: write
4141
timeout-minutes: 90
4242
env:
43+
# 稳定版基础版本名;pre-release 在其后追加 -Pre。手动填 Version Name 时以手动值为准。
44+
BASE_VERSION_NAME: '3.0.1-Rustic-JNI'
4345
CARGO_TARGET_DIR: ${{ github.workspace }}/source/native/src/main/jni/external/rustic/rustic/target
4446
steps:
4547
- name: Checkout
@@ -172,11 +174,19 @@ jobs:
172174
COMMIT_SUBJECT=$(git log -1 --pretty=%s)
173175
echo "commit_subject=$COMMIT_SUBJECT" >> $GITHUB_OUTPUT
174176
175-
# 确定版本名称
176-
if [ -n "${{ github.event.inputs.version_name }}" ]; then
177-
VERSION_NAME="${{ github.event.inputs.version_name }}"
177+
# 确定版本名称:手动填写优先;留空时按 Release Type 联动默认值
178+
INPUT_VERSION_NAME="$(echo "${{ github.event.inputs.version_name }}" | xargs)"
179+
INPUT_RELEASE_TYPE="${{ github.event.inputs.release_type }}"
180+
if [ "${INPUT_RELEASE_TYPE}" = 'release' ]; then
181+
DEFAULT_VERSION_NAME="${BASE_VERSION_NAME}"
178182
else
179-
VERSION_NAME=$(grep "versionName" gradle/libs.versions.toml | cut -d'"' -f2)
183+
DEFAULT_VERSION_NAME="${BASE_VERSION_NAME}-Pre"
184+
fi
185+
echo "Default Version Name: $DEFAULT_VERSION_NAME (release_type=${INPUT_RELEASE_TYPE})"
186+
if [ -n "${INPUT_VERSION_NAME}" ]; then
187+
VERSION_NAME="${INPUT_VERSION_NAME}"
188+
else
189+
VERSION_NAME="${DEFAULT_VERSION_NAME}"
180190
fi
181191
echo "name=$VERSION_NAME" >> $GITHUB_OUTPUT
182192

‎README.md‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,13 @@
3838
| **本地存储 / USB OTG外部存储** | ✅ 已支持 | ✅ **块级去重(JNI rustic,已完成)** |
3939
| **AWS S3(兼容Minio Rustfs) 协议** | ❌ 不支持 | ✅ **块级去重(JNI rustic,已完成)** |
4040
| **Tencent COS 协议** | ❌ 不支持 | ✅ **块级去重(JNI rustic,已完成)** |
41-
| **Aliyun OSS 协议** | ❌ 不支持 | ❗ **块级去重(JNI rustic,待实现)** |
42-
| **HuaWei OBS 协议** | ❌ 不支持 | ❗ **块级去重(JNI rustic,待实现)** |
41+
| **Aliyun OSS 协议** | ❌ 不支持 | ✅ **块级去重(JNI rustic,已完成)** |
42+
| **HuaWei OBS 协议** | ❌ 不支持 | ✅ **块级去重(JNI rustic,已完成)** |
4343
| **FTP 协议** | ✅ 已支持 | ✅ **块级去重(JNI rustic over librclone,已完成)** |
4444
| **SFTP 协议** | ✅ 已支持 | ✅ **块级去重(JNI rustic over librclone,已完成)** |
4545
| **WebDAV 协议** | ✅ 已支持 | ✅ **块级去重(JNI rustic,已完成)** |
4646
| **SMB/CIFS 协议** | ✅ 已支持 | ✅ **块级去重(JNI rustic over librclone,已完成)** |
4747

48-
> 阿里云 OOS、华为云OBS:在逐步适配中,敬请期待.
49-
5048
### 备份架构演进
5149

5250
| 功能 | 旧版 | 新版 (已完成) |

‎README_en.md‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,13 @@
3838
| **Local storage / USB OTG** | ✅ Supported | ✅ **Block-level dedup (JNI rustic, done)** |
3939
| **AWS S3 (Minio/Rustfs compatible)** | ❌ Not supported | ✅ **Block-level dedup (JNI rustic, done)** |
4040
| **Tencent COS** | ❌ Not supported | ✅ **Block-level dedup (JNI rustic, done)** |
41-
| **Aliyun OSS** | ❌ Not supported | ❗ **Block-level dedup (JNI rustic, WIP)** |
42-
| **HuaWei OBS** | ❌ Not supported | ❗ **Block-level dedup (JNI rustic, WIP)** |
41+
| **Aliyun OSS** | ❌ Not supported | ✅ **Block-level dedup (JNI rustic, done)** |
42+
| **HuaWei OBS** | ❌ Not supported | ✅ **Block-level dedup (JNI rustic, done)** |
4343
| **FTP** | ✅ Supported | ✅ **Block-level dedup (JNI rustic over librclone, done)** |
4444
| **SFTP** | ✅ Supported | ✅ **Block-level dedup (JNI rustic over librclone, done)** |
4545
| **WebDAV** | ✅ Supported | ✅ **Block-level dedup (JNI rustic, done)** |
4646
| **SMB/CIFS** | ✅ Supported | ✅ **Block-level dedup (JNI rustic over librclone, done)** |
4747

48-
> Aliyun OSS, HuaWei OBS: being adapted progressively — stay tuned.
49-
5048
### Backup Architecture Evolution
5149

5250
| Feature | Old | New (Done) |

‎source/app/src/main/kotlin/com/xayah/databackup/MainActivity.kt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import com.xayah.feature.main.cloud.add.PageWebDAVSetup
5555
import com.xayah.feature.main.cloud.add.PageS3Setup
5656
import com.xayah.feature.main.cloud.add.PageAwsS3Setup
5757
import com.xayah.feature.main.cloud.add.PageAliyunOssSetup
58+
import com.xayah.feature.main.cloud.add.PageHuaweiObsSetup
5859
import com.xayah.feature.main.configurations.PageConfigurations
5960
import com.xayah.feature.main.dashboard.PageDashboard
6061
import com.xayah.feature.main.details.DetailsRoute
@@ -199,6 +200,9 @@ class MainActivity : AppCompatActivity() {
199200
composable(MainRoutes.AliyunOssSetup.route) {
200201
PageAliyunOssSetup()
201202
}
203+
composable(MainRoutes.HuaweiObsSetup.route) {
204+
PageHuaweiObsSetup()
205+
}
202206
composable(
203207
route = MainRoutes.List.route,
204208
arguments = listOf(

‎source/core/datastore/src/main/kotlin/com/xayah/core/datastore/DbPreferencesDataSource.kt‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ val KeyAliyunOssResticRepoPath = stringPreferencesKey("aliyun_oss_restic_repo_pa
3737
val KeyAliyunOssResticPassword = stringPreferencesKey("aliyun_oss_restic_password")
3838
val KeyAliyunOssResticInitialized = booleanPreferencesKey("aliyun_oss_restic_initialized")
3939

40+
// 华为云 OBS Restic 配置键
41+
val KeyHuaweiObsResticRepoPath = stringPreferencesKey("huawei_obs_restic_repo_path")
42+
val KeyHuaweiObsResticPassword = stringPreferencesKey("huawei_obs_restic_password")
43+
val KeyHuaweiObsResticInitialized = booleanPreferencesKey("huawei_obs_restic_initialized")
44+
4045
// FTP Restic 配置键
4146
val KeyFtpResticRepoPath = stringPreferencesKey("ftp_restic_repo_path")
4247
val KeyFtpResticPassword = stringPreferencesKey("ftp_restic_password")
@@ -191,6 +196,43 @@ suspend fun Context.readAliyunOssResticRepoPath(): String? {
191196
}.first()
192197
}
193198

199+
// 华为云 OBS Restic 配置扩展函数
200+
suspend fun Context.saveHuaweiObsResticPassword(password: String) {
201+
dataStore.edit { settings ->
202+
settings[KeyHuaweiObsResticPassword] = password
203+
}
204+
}
205+
206+
suspend fun Context.readHuaweiObsResticPassword(): String? {
207+
return dataStore.data.map { preferences ->
208+
preferences[KeyHuaweiObsResticPassword]
209+
}.first()
210+
}
211+
212+
suspend fun Context.saveHuaweiObsResticInitialized(initialized: Boolean) {
213+
dataStore.edit { settings ->
214+
settings[KeyHuaweiObsResticInitialized] = initialized
215+
}
216+
}
217+
218+
suspend fun Context.readHuaweiObsResticInitialized(): Boolean {
219+
return dataStore.data.map { preferences ->
220+
preferences[KeyHuaweiObsResticInitialized] ?: false
221+
}.first()
222+
}
223+
224+
suspend fun Context.saveHuaweiObsResticRepoPath(path: String) {
225+
dataStore.edit { settings ->
226+
settings[KeyHuaweiObsResticRepoPath] = path
227+
}
228+
}
229+
230+
suspend fun Context.readHuaweiObsResticRepoPath(): String? {
231+
return dataStore.data.map { preferences ->
232+
preferences[KeyHuaweiObsResticRepoPath]
233+
}.first()
234+
}
235+
194236
// FTP Restic 配置扩展函数
195237
suspend fun Context.saveFtpResticPassword(password: String) {
196238
dataStore.edit { settings ->

‎source/core/model/src/main/kotlin/com/xayah/core/model/Enum.kt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ enum class CloudType(val title: String) {
9898
S3("Tencent Cloud COS"),
9999
AWSS3("Amazon S3"),
100100
ALIYUNOSS("Aliyun OSS"),
101+
HUAWEIOBS("Huawei Cloud OBS"),
101102
}
102103

103104
enum class SFTPAuthMode(val index: Int) {

‎source/core/model/src/main/kotlin/com/xayah/core/model/database/CloundEntity.kt‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,29 @@ enum class AliyunOssProtocol {
9696
HTTPS
9797
}
9898

99+
/**
100+
* 华为云 OBS 账户附加配置。
101+
* 字段与 opendal 0.57 `opendal-service-obs` 的 ObsConfig 一一对应:
102+
* bucket / endpoint / access_key_id / secret_access_key(OBS 无 region,地域由 endpoint 表达)。
103+
* endpoint 必须填写(如 obs.cn-north-4.myhuaweicloud.com);OBS SDK 会自行拼接
104+
* https://{bucket}.{endpoint},因此下发前一律剥离 scheme,protocol 仅用于界面地址预览。
105+
*/
106+
@Serializable
107+
data class HuaweiObsExtra(
108+
val type: String = "HUAWEIOBS",
109+
val accessKeyId: String,
110+
val secretAccessKey: String,
111+
val bucket: String,
112+
val endpoint: String = "",
113+
val protocol: HuaweiObsProtocol = HuaweiObsProtocol.HTTPS,
114+
val resticPassword: String = "",
115+
)
116+
117+
enum class HuaweiObsProtocol {
118+
HTTP,
119+
HTTPS
120+
}
121+
99122
@Entity
100123
data class CloudEntity(
101124
@PrimaryKey var name: String,

‎source/core/network/src/main/kotlin/com/xayah/core/network/client/CloudClient.kt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import com.xayah.core.rootservice.parcelables.PathParcelable
1111
import com.xayah.libpickyou.parcelables.DirChildrenParcelable
1212
import com.xayah.core.model.database.S3Extra
1313
import com.xayah.core.model.database.AliyunOssExtra
14+
import com.xayah.core.model.database.HuaweiObsExtra
1415
import com.xayah.core.model.database.AwsS3Extra
1516
import com.xayah.core.model.database.SMBExtra
1617
import com.xayah.core.rootservice.service.RemoteRootService
@@ -70,6 +71,11 @@ fun CloudEntity.getCloud(rootService: RemoteRootService) = when (this.type) {
7071
AliyunOssClientImpl(this, extra, rootService)
7172
}
7273

74+
CloudType.HUAWEIOBS -> {
75+
val extra = getExtraEntity<HuaweiObsExtra>()!!
76+
HuaweiObsClientImpl(this, extra, rootService)
77+
}
78+
7379
CloudType.SMB -> {
7480
val extra = getExtraEntity<SMBExtra>()!!
7581
SMBClientImpl(this, extra, rootService)

0 commit comments

Comments
 (0)