Skip to content

Enhance WebDAV snapshot backup safety - #5

Merged
blrain3 merged 1 commit into
masterfrom
dev
Jun 2, 2026
Merged

Enhance WebDAV snapshot backup safety#5
blrain3 merged 1 commit into
masterfrom
dev

Conversation

@blrain3

@blrain3 blrain3 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings June 2, 2026 00:02
@ecc-tools

ecc-tools Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves WebDAV sync safety by ensuring a remote snapshot backup is created before uploading a new snapshot, and by restoring the previous remote snapshot if an upload fails.

Changes:

  • Add a “backup error” sync result state/message and surface it via string resources.
  • Introduce safe snapshot upload helpers (backup-before-upload + restore-on-failure) and parse helper for remote payload validation.
  • Make WebDAV backup naming deterministic (*.backup.json) and add unit tests for the new behaviors.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
app/src/main/java/net/micode/notes/sync/webdav/WebDavSyncManager.java Adds backup-safe upload/restore flow, backup error state, and parsing helpers.
app/src/main/java/net/micode/notes/sync/webdav/WebDavClient.java Implements new transport interface and switches backup URL to deterministic naming.
app/src/test/java/net/micode/notes/sync/webdav/WebDavSyncManagerTest.java Adds unit tests for safe upload, backup failure behavior, and snapshot parsing.
app/src/test/java/net/micode/notes/sync/webdav/WebDavClientTest.java Updates tests for new deterministic backup URL behavior/signature.
app/build.gradle Adds org.json dependency for JVM unit tests.
res/values/strings.xml Adds backup error user-facing message (legacy packaged resources).
res/values-zh-rTW/strings.xml Adds Traditional Chinese backup error translation (legacy packaged resources).
res/values-zh-rCN/strings.xml Adds Simplified Chinese backup error translation (legacy packaged resources).
app/src/main/values/strings.xml Adds backup error message in duplicate (currently unused) resource tree.
app/src/main/values-zh-rTW/strings.xml Adds translation in duplicate (currently unused) resource tree.
app/src/main/values-zh-rCN/strings.xml Adds translation in duplicate (currently unused) resource tree.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +383 to 392
static void backupSnapshotSafely(SnapshotTransport client, String snapshot)
throws IOException {
if (!TextUtils.isEmpty(remotePayload)) {
client.putBackupSnapshot(remotePayload, System.currentTimeMillis());
if (isEmpty(snapshot)) {
return;
}
try {
client.putBackupSnapshot(snapshot);
} catch (IOException e) {
throw new SnapshotBackupException(e);
}
Comment on lines 114 to +117
<string name="sync_result_auth_error">WebDAV sync failed: check username and password</string>
<string name="sync_result_path_error">WebDAV sync failed: check WebDAV path and permissions</string>
<string name="sync_result_remote_not_found">WebDAV snapshot was not found. Sync once to create mi-notes-sync.json, or check the path.</string>
<string name="sync_result_backup_error">WebDAV sync failed: backup could not be created, so existing data was not changed</string>
Comment on lines 109 to +112
<string name="sync_result_auth_error">WebDAV 同步失敗:請檢查使用者名稱和密碼</string>
<string name="sync_result_path_error">WebDAV 同步失敗:請檢查 WebDAV 路徑和權限</string>
<string name="sync_result_remote_not_found">未找到 WebDAV 快照。請同步一次以建立 mi-notes-sync.json,或檢查路徑。</string>
<string name="sync_result_backup_error">WebDAV 同步失敗:無法建立備份,現有資料未被變更</string>
Comment on lines 110 to +113
<string name="sync_result_auth_error">WebDAV 同步失败:请检查用户名和密码</string>
<string name="sync_result_path_error">WebDAV 同步失败:请检查 WebDAV 路径和权限</string>
<string name="sync_result_remote_not_found">未找到 WebDAV 快照。请同步一次以创建 mi-notes-sync.json,或检查路径。</string>
<string name="sync_result_backup_error">WebDAV 同步失败:无法创建备份,现有数据未被更改</string>
blrain3 added a commit that referenced this pull request Jun 15, 2026
Enhance WebDAV snapshot backup safety
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants