clawkeep 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/backup.js +5 -15
- package/src/core/transport.js +4 -4
package/package.json
CHANGED
package/src/core/backup.js
CHANGED
|
@@ -141,13 +141,12 @@ class BackupManager {
|
|
|
141
141
|
|
|
142
142
|
let result;
|
|
143
143
|
let transport;
|
|
144
|
-
let syncManager;
|
|
145
144
|
if (target === 'local' || target === 's3' || target === 'cloud') {
|
|
146
145
|
// Encrypted incremental sync (local, S3, or cloud)
|
|
147
146
|
if (!password) throw new Error('Password required for encrypted sync');
|
|
148
147
|
transport = createTransport(backup, this.claw);
|
|
149
|
-
|
|
150
|
-
result = await
|
|
148
|
+
const sm = new SyncManager(this.claw, transport, password);
|
|
149
|
+
result = await sm.sync();
|
|
151
150
|
} else if (target === 'git') {
|
|
152
151
|
await this.claw.push();
|
|
153
152
|
result = { ok: true, target: 'git', synced: true };
|
|
@@ -158,19 +157,10 @@ class BackupManager {
|
|
|
158
157
|
freshConfig.backup.lastSync = new Date().toISOString();
|
|
159
158
|
this.claw.saveConfig(freshConfig);
|
|
160
159
|
|
|
161
|
-
//
|
|
160
|
+
// Notify cloud API that a sync occurred (fire-and-forget)
|
|
161
|
+
// The API reads real stats from R2 — we just ping it.
|
|
162
162
|
if (target === 'cloud' && transport && transport.reportSync) {
|
|
163
|
-
|
|
164
|
-
// Get accurate stats from manifest (result may be "already up to date" with no sizes)
|
|
165
|
-
const status = await syncManager.getStatus();
|
|
166
|
-
const chunkCount = status.chunkCount || freshConfig.backup.chunkCount || 0;
|
|
167
|
-
const totalSize = status.totalSize || 0;
|
|
168
|
-
transport.reportSync({ chunkCount, totalSize }).catch(() => {});
|
|
169
|
-
} catch {
|
|
170
|
-
// Fall back to result data if getStatus fails
|
|
171
|
-
const chunkCount = freshConfig.backup.chunkCount || result.chunkCount || 0;
|
|
172
|
-
transport.reportSync({ chunkCount, totalSize: result.totalSize || 0 }).catch(() => {});
|
|
173
|
-
}
|
|
163
|
+
transport.reportSync().catch(() => {});
|
|
174
164
|
}
|
|
175
165
|
|
|
176
166
|
return { ...result, lastSync: freshConfig.backup.lastSync };
|
package/src/core/transport.js
CHANGED
|
@@ -182,11 +182,11 @@ class CloudTransport extends BackupTransport {
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
/**
|
|
185
|
-
*
|
|
185
|
+
* Notify the cloud API that a sync occurred (fire-and-forget).
|
|
186
|
+
* The API reads actual stats from R2 — we just ping it.
|
|
186
187
|
*/
|
|
187
|
-
async reportSync(
|
|
188
|
+
async reportSync() {
|
|
188
189
|
const url = `${this.endpoint}/api/workspaces/${this.workspace}/sync-report`;
|
|
189
|
-
const body = JSON.stringify({ chunk_count: chunkCount, storage_bytes: totalSize });
|
|
190
190
|
try {
|
|
191
191
|
await new Promise((resolve, reject) => {
|
|
192
192
|
const parsed = new URL(url);
|
|
@@ -204,7 +204,7 @@ class CloudTransport extends BackupTransport {
|
|
|
204
204
|
});
|
|
205
205
|
req.on('error', reject);
|
|
206
206
|
req.setTimeout(15000, () => req.destroy(new Error('Sync report timeout')));
|
|
207
|
-
req.end(
|
|
207
|
+
req.end('{}');
|
|
208
208
|
});
|
|
209
209
|
} catch {
|
|
210
210
|
// Fire-and-forget: don't fail the sync if report fails
|