数据同步支持接入第三方 WebDAV 服务 https://github.com/siyuan-note/siyuan/issues/6446

This commit is contained in:
Liang Ding 2022-11-02 23:33:05 +08:00
parent d7f6456424
commit b6a1512105
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
6 changed files with 87 additions and 30 deletions

View file

@ -17,14 +17,16 @@
package conf
type Sync struct {
CloudName string `json:"cloudName"` // 云端同步目录名称
Enabled bool `json:"enabled"` // 是否开启同步
Mode int `json:"mode"` // 同步模式0未设置为兼容已有配置initConf 函数中会转换为 11自动2手动 https://github.com/siyuan-note/siyuan/issues/5089
Synced int64 `json:"synced"` // 最近同步时间
Stat string `json:"stat"` // 最近同步统计信息
GenerateConflictDoc bool `json:"generateConflictDoc"` // 云端同步冲突时是否生成冲突文档
Provider int `json:"provider"` // 云端存储服务提供者0思源官方1第三方七牛云2S3 协议对象存储
OSS *OSS `json:"oss"` // 对象存储服务配置
CloudName string `json:"cloudName"` // 云端同步目录名称
Enabled bool `json:"enabled"` // 是否开启同步
Mode int `json:"mode"` // 同步模式0未设置为兼容已有配置initConf 函数中会转换为 11自动2手动 https://github.com/siyuan-note/siyuan/issues/5089
Synced int64 `json:"synced"` // 最近同步时间
Stat string `json:"stat"` // 最近同步统计信息
GenerateConflictDoc bool `json:"generateConflictDoc"` // 云端同步冲突时是否生成冲突文档
Provider int `json:"provider"` // 云端存储服务提供者
Qiniu *Qiniu `json:"qiniu"` // 七牛云存储服务配置
S3 *S3 `json:"s3"` // S3 对象存储服务配置
WebDAV *WebDAV `json:"webdav"` // WebDAV 服务配置
}
func NewSync() *Sync {
@ -37,7 +39,14 @@ func NewSync() *Sync {
}
}
type OSS struct {
type Qiniu struct {
Endpoint string `json:"endpoint"` // 服务端点
AccessKey string `json:"accessKey"` // Access Key
SecretKey string `json:"secretKey"` // Secret Key
Bucket string `json:"bucket"` // 存储空间
}
type S3 struct {
Endpoint string `json:"endpoint"` // 服务端点
AccessKey string `json:"accessKey"` // Access Key
SecretKey string `json:"secretKey"` // Secret Key
@ -45,8 +54,15 @@ type OSS struct {
Region string `json:"region"` // 存储区域
}
type WebDAV struct {
Endpoint string `json:"endpoint"` // 服务端点
Username string `json:"username"` // 用户名
Password string `json:"password"` // 密码
}
const (
ProviderSiYuan = 0
ProviderQiniu = 1
ProviderS3 = 2
ProviderSiYuan = 0 // ProviderSiYuan 为思源官方提供的云端存储服务
ProviderQiniu = 1 // ProviderQiniu 为第三方七牛云提供的云端存储服务
ProviderS3 = 2 // ProviderS3 为 S3 协议对象存储提供的云端存储服务
ProviderWebDAV = 3 // ProviderWebDAV 为 WebDAV 协议提供的云端存储服务
)