mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Support local file system sync & backup (#13663)
* 🎨 Use local file system sync & backup * ⬆️ dejavu * 🎨 Add the settings panel of local file system sync & backup * 📝 Update user guides of local file system sync & backup * 🎨 Adjust supported runtime environments
This commit is contained in:
parent
0386bc9ebd
commit
6ee4705e2a
27 changed files with 408 additions and 32 deletions
|
|
@ -252,7 +252,7 @@ func checkSync(boot, exit, byHand bool) bool {
|
|||
if !IsSubscriber() {
|
||||
return false
|
||||
}
|
||||
case conf.ProviderWebDAV, conf.ProviderS3:
|
||||
case conf.ProviderWebDAV, conf.ProviderS3, conf.ProviderLocal:
|
||||
if !IsPaidUser() {
|
||||
return false
|
||||
}
|
||||
|
|
@ -471,13 +471,28 @@ func SetSyncProviderWebDAV(webdav *conf.WebDAV) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func SetSyncProviderLocal(local *conf.Local) (err error) {
|
||||
local.Endpoint = strings.TrimSpace(local.Endpoint)
|
||||
local.Endpoint = util.NormalizeLocalPath(local.Endpoint)
|
||||
|
||||
local.Timeout = util.NormalizeTimeout(local.Timeout)
|
||||
local.ConcurrentReqs = util.NormalizeConcurrentReqs(local.ConcurrentReqs, conf.ProviderLocal)
|
||||
|
||||
Conf.Sync.Local = local
|
||||
Conf.Save()
|
||||
return
|
||||
}
|
||||
|
||||
var (
|
||||
syncLock = sync.Mutex{}
|
||||
isSyncing = atomic.Bool{}
|
||||
)
|
||||
|
||||
func CreateCloudSyncDir(name string) (err error) {
|
||||
if conf.ProviderSiYuan != Conf.Sync.Provider {
|
||||
switch Conf.Sync.Provider {
|
||||
case conf.ProviderSiYuan, conf.ProviderLocal:
|
||||
break
|
||||
default:
|
||||
err = errors.New(Conf.Language(131))
|
||||
return
|
||||
}
|
||||
|
|
@ -502,7 +517,10 @@ func CreateCloudSyncDir(name string) (err error) {
|
|||
}
|
||||
|
||||
func RemoveCloudSyncDir(name string) (err error) {
|
||||
if conf.ProviderSiYuan != Conf.Sync.Provider {
|
||||
switch Conf.Sync.Provider {
|
||||
case conf.ProviderSiYuan, conf.ProviderLocal:
|
||||
break
|
||||
default:
|
||||
err = errors.New(Conf.Language(131))
|
||||
return
|
||||
}
|
||||
|
|
@ -678,6 +696,9 @@ func isProviderOnline(byHand bool) (ret bool) {
|
|||
checkURL = Conf.Sync.WebDAV.Endpoint
|
||||
skipTlsVerify = Conf.Sync.WebDAV.SkipTlsVerify
|
||||
timeout = Conf.Sync.WebDAV.Timeout * 1000
|
||||
case conf.ProviderLocal:
|
||||
checkURL = "file://" + Conf.Sync.Local.Endpoint
|
||||
timeout = Conf.Sync.Local.Timeout * 1000
|
||||
default:
|
||||
logging.LogWarnf("unknown provider: %d", Conf.Sync.Provider)
|
||||
return false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue