Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

cr4sync sync

[sync] 配置同步本地 ↔ Cloudreve。所有 diff / 传输 / 校验由 sync-core SyncEngine 承担,cr4sync 只做编排 + 进度展示。

用法

cr4sync sync                          # 使用配置文件中的 sync_mode
cr4sync sync --mode single
cr4sync sync --mode incremental
cr4sync sync --mode append
cr4sync sync --mode two_way

参数

参数类型默认说明
--mode <MODE>enum[sync].sync_mode临时覆盖同步模式,不写回配置文件。可选值见下表。

模式映射

--modesync-core SyncMode行为
singleUploadOnly仅上传。run_initial_sync 跑完即退出。
incrementalUploadOnly仅上传。run_initial_sync 跑完后进入 run_continuous,Ctrl-C 停止。
appendUploadOnly仅持续监听,跳过 initial。
two_wayFull双向。run_initial_sync 跑完即退出(上传本地新增 + 下载远端新增 + 冲突按 sync_conflict 解)。

配置热更新

incremental / append 模式下运行期支持热更新 cr4sync.toml

  • 软更新(引擎内重读):sync_conflict, parallelism, 日志 level / mode 即时生效。
  • 硬重建(停旧引擎重建):src / target / worker / parallelism 这几个被 sync-core WorkerPool 构造时快照、运行期不重读的字段。cr4sync 外层 loop 检测到变更后 engine.stop() → 丢旧 Arc → 用新 config SyncEngine::new

进度展示

indicatif::MultiProgress 渲染:

  • 文件级粒度(completed/total + running item 名称)
  • 多 worker 并发情况下底部常驻 N 条 spinner(N = 并发数,上限 512)
  • log 与 bar 协同:MultiProgress::suspend 让位写日志再重画 bar

已知限制

  1. UploadOnly 持续阶段冲突一律覆盖:sync-core 在 UploadOnly 的 continuous 阶段把冲突强制映射为 KeepLocal。sync_conflict = "skip" 在持续阶段实际仍上传覆盖。two_way 模式下 skip / overwrite 才完整生效。
  2. 远端 hash 不可得:sync-core 内容比对依赖 mtime + size,“同大小且 mtime 未变的篡改“理论上可漏判。
  3. sync 阶段无字节级进度:只显示文件级,单文件字节进度走 up / dl 子命令。

配置示例

[serve.cr4]
server_url = "https://demo.cloudreve.org"

[db]
type = "sqlite3"
path = "./data"

[sync]
src           = "/home/data"
target        = "/"
worker        = 4
parallelism   = 8
sync_mode     = "incremental"
sync_conflict = "skip"