Skip to content

[Bug]: WebDAV Backup Restore Fails with EBUSY Error on agents.db #12924

@stan1233

Description

@stan1233

Note

This issue was translated by Claude.

Issue Checklist

  • I understand that issues are for feedback and problem solving, not for complaining in the comment section, and will provide as much information as possible to help solve the problem.
  • My issue is not listed in the FAQ.
  • I've looked at pinned issues and searched for existing Open Issues, Closed Issues, and Discussions, no similar issue or discussion was found.
  • I've filled in short, clear headings so that developers can quickly identify a rough idea of what to expect when flipping through the list of issues. And not "a suggestion", "stuck", etc.
  • I've confirmed that I am using the latest version of Cherry Studio.

Platform

Windows

Version

v1.7.18

Bug Description

Nutstore restore failed

When restoring a backup via WebDAV (Jianguoyun / NutStore), the following error occurs:

Restore failed
Error invoking remote method 'backup:restoreFromWebdav': Error: EBUSY: resource busy or locked, unlink 'C:\\Users\\<username>\\AppData\\Roaming\\CherryStudio\\Data\\agents.db'

Investigation using Windows Resource Monitor confirmed that the process holding the lock on agents.db is Cherry Studio itself (Cherry Studio.exe), not any third-party software (e.g., OneDrive, antivirus, etc.).

This indicates that during the restore process, Cherry Studio attempts to unlink (delete) the agents.db file without first closing its own SQLite database connection, resulting in the file being locked by its own process.

Expected Behavior

During backup restoration, Cherry Studio should close its database connection to agents.db before attempting to replace the file, ensuring the restore process completes successfully.

Diagnostic Information

Confirmed via Windows Resource Monitor (CPU → Associated Handles → search agents.db):

  • Locking process: Cherry Studio.exe (PID: 147548)
  • Locked file path: C:\\Users\\<username>\\AppData\\Roaming\\CherryStudio\\Data\\agents.db
  • Ruled out interference from OneDrive, antivirus, or other third-party software

Screenshots

Image

Steps To Reproduce

  1. Use Cherry Studio normally, ensuring Agent data exists (agents.db is present)
  2. Go to Settings → Data Settings → WebDAV Cloud Backup (using Jianguoyun/NutStore)
  3. Select a backup file and click "Restore"
  4. Error appears: EBUSY: resource busy or locked, unlink ...agents.db

Expected Behavior

In the restore flow of BackupManager (restoreFromWebdav and related methods), close the SQLite database connection to agents.db before performing file replacement (unlink / rename). Re-establish the connection after the restore is complete.

Note: This issue may be related to PR #12830 (fix(agent): move agents.db into Data/ directory for backup consistency), but #12830 addressed path consistency while this issue concerns resource release during restoration.

Relevant Log Output

Additional Context

No response


Original Content

Issue Checklist

  • I understand that issues are for feedback and problem solving, not for complaining in the comment section, and will provide as much information as possible to help solve the problem.
  • My issue is not listed in the FAQ.
  • I've looked at pinned issues and searched for existing Open Issues, Closed Issues, and Discussions, no similar issue or discussion was found.
  • I've filled in short, clear headings so that developers can quickly identify a rough idea of what to expect when flipping through the list of issues. And not "a suggestion", "stuck", etc.
  • I've confirmed that I am using the latest version of Cherry Studio.

Platform

Windows

Version

v1.7.18

Bug Description

坚果云恢复失败/Nutstore restore failed

中文

通过 WebDAV(坚果云 / Jianguoyun)恢复备份时,出现以下错误:

恢复失败
Error invoking remote method 'backup:restoreFromWebdav': Error: EBUSY: resource busy or locked, unlink 'C:\\Users\\<username>\\AppData\\Roaming\\CherryStudio\\Data\\agents.db'

通过 Windows 资源监视器(Resource Monitor)排查发现,锁定 agents.db 文件的进程正是 Cherry Studio 自身(Cherry Studio.exe),而非任何第三方程序(如 OneDrive、杀毒软件等)。

这说明在执行恢复操作时,Cherry Studio 没有先释放对 agents.db 的 SQLite 数据库连接,就尝试 unlink(删除)该文件以进行替换,导致文件被自身进程锁定而无法删除。

English

When restoring a backup via WebDAV (Jianguoyun / NutStore), the following error occurs:

Restore failed
Error invoking remote method 'backup:restoreFromWebdav': Error: EBUSY: resource busy or locked, unlink 'C:\\Users\\<username>\\AppData\\Roaming\\CherryStudio\\Data\\agents.db'

Investigation using Windows Resource Monitor confirmed that the process holding the lock on agents.db is Cherry Studio itself (Cherry Studio.exe), not any third-party software (e.g., OneDrive, antivirus, etc.).

This indicates that during the restore process, Cherry Studio attempts to unlink (delete) the agents.db file without first closing its own SQLite database connection, resulting in the file being locked by its own process.

预期行为 / Expected Behavior

中文

恢复备份时,Cherry Studio 应先关闭对 agents.db 的数据库连接,然后再执行文件替换操作,确保恢复流程正常完成。

English

During backup restoration, Cherry Studio should close its database connection to agents.db before attempting to replace the file, ensuring the restore process completes successfully.

排查信息 / Diagnostic Information

通过 Windows 资源监视器(CPU → 关联的句柄 → 搜索 agents.db)确认:

  • 锁定进程:Cherry Studio.exe(PID: 147548)
  • 锁定文件路径:C:\\Users\\<username>\\AppData\\Roaming\\CherryStudio\\Data\\agents.db
  • 已排除 OneDrive、杀毒软件等第三方程序干扰

Confirmed via Windows Resource Monitor (CPU → Associated Handles → search agents.db):

  • Locking process: Cherry Studio.exe (PID: 147548)
  • Locked file path: C:\\Users\\<username>\\AppData\\Roaming\\CherryStudio\\Data\\agents.db
  • Ruled out interference from OneDrive, antivirus, or other third-party software

截图 / Screenshots

Image

Steps To Reproduce

  1. 正常使用 Cherry Studio,确保有 Agent 数据(agents.db 存在)
  2. 进入 设置 → 数据设置 → WebDAV 云备份(使用坚果云)
  3. 选择一个备份文件,点击"恢复"
  4. 弹出错误提示:EBUSY: resource busy or locked, unlink ...agents.db

  1. Use Cherry Studio normally, ensuring Agent data exists (agents.db is present)
  2. Go to Settings → Data Settings → WebDAV Cloud Backup (using Jianguoyun/NutStore)
  3. Select a backup file and click "Restore"
  4. Error appears: EBUSY: resource busy or locked, unlink ...agents.db

Expected Behavior

BackupManager 的恢复流程(restoreFromWebdav 等方法)中,在执行文件替换(unlink / rename)之前,先关闭对 agents.db 的 SQLite 数据库连接。恢复完成后再重新建立连接。

注意:此问题可能与 PR #12830fix(agent): move agents.db into Data/ directory for backup consistency)相关,但 #12830 解决的是路径一致性问题,而本 issue 是恢复时的资源释放问题。

In the restore flow of BackupManager (restoreFromWebdav and related methods), close the SQLite database connection to agents.db before performing file replacement (unlink / rename). Re-establish the connection after the restore is complete.

Note: This issue may be related to PR #12830 (fix(agent): move agents.db into Data/ directory for backup consistency), but #12830 addressed path consistency while this issue concerns resource release during restoration.

Relevant Log Output

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BUGCategorizes issue or PR as related to a bugDataCategorizes an issue or PR as relevant to SIG Data

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions