@pandablessing/dsh-user-sync 1.0.12 → 1.0.14
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/lib/client.js +20 -2
- package/lib/sync.js +2 -1
- package/package.json +2 -2
package/lib/client.js
CHANGED
|
@@ -147,6 +147,7 @@ if (typeof window !== 'undefined' && window.__ModuleLoader__) {
|
|
|
147
147
|
'remote-missing': '远端无包',
|
|
148
148
|
};
|
|
149
149
|
/** 最近一次同步的摘要:上传 / 应用 / 检查。 */
|
|
150
|
+
/** 最近一次同步的摘要:上传 / 应用 / 检查。 */
|
|
150
151
|
function lastSyncSummary(status) {
|
|
151
152
|
if (!status)
|
|
152
153
|
return '尚未同步';
|
|
@@ -158,7 +159,12 @@ if (typeof window !== 'undefined' && window.__ModuleLoader__) {
|
|
|
158
159
|
if (status.scheduler?.lastCheckAt) {
|
|
159
160
|
const decision = status.scheduler.lastDecision;
|
|
160
161
|
const label = decision?.action && DECISION_LABELS[decision.action] ? DECISION_LABELS[decision.action] : '';
|
|
161
|
-
|
|
162
|
+
// 检查结论只在「没有比它更新的上传/应用」时才算数:否则显示「发现更新」会与上传时间矛盾
|
|
163
|
+
const checkAt = Date.parse(status.scheduler.lastCheckAt);
|
|
164
|
+
const newerAt = Math.max(status.lastUploaded?.createdAt ? Date.parse(status.lastUploaded.createdAt) : Number.NEGATIVE_INFINITY, status.lastApplied?.createdAt ? Date.parse(status.lastApplied.createdAt) : Number.NEGATIVE_INFINITY);
|
|
165
|
+
const stale = Number.isFinite(checkAt) && newerAt > checkAt;
|
|
166
|
+
const suffix = label && !stale ? `(${label})` : '';
|
|
167
|
+
parts.push(`上次检查 ${fmtTime(status.scheduler.lastCheckAt)}${suffix}`);
|
|
162
168
|
}
|
|
163
169
|
return parts.length > 0 ? parts.join(' · ') : '尚未同步';
|
|
164
170
|
}
|
|
@@ -421,7 +427,19 @@ if (typeof window !== 'undefined' && window.__ModuleLoader__) {
|
|
|
421
427
|
});
|
|
422
428
|
}
|
|
423
429
|
else {
|
|
424
|
-
|
|
430
|
+
// 常见失败给出可操作的提示(服务端错误码透传到 result.code)
|
|
431
|
+
const friendly = {
|
|
432
|
+
'quota-exceeded': '远端配额已满:请联系维护者清理旧包,或稍后再试。',
|
|
433
|
+
'package-too-large': '包超过 10 MiB 上限:请减少同步范围(取消项目记忆/大文件)后重试。',
|
|
434
|
+
'E_LOCKED': '另一台设备正在同步,请稍后再试。',
|
|
435
|
+
};
|
|
436
|
+
const hint = typeof result.code === 'string' ? friendly[result.code] : undefined;
|
|
437
|
+
setNotice({
|
|
438
|
+
kind: 'error',
|
|
439
|
+
data: hint
|
|
440
|
+
? { ...result, detail: `${hint}(${result.detail ?? result.code})` }
|
|
441
|
+
: { ...result, detail: result.detail ?? '上传失败:远端存储可能空间不足或不可用,请联系维护者。' },
|
|
442
|
+
});
|
|
425
443
|
}
|
|
426
444
|
refresh();
|
|
427
445
|
}
|
package/lib/sync.js
CHANGED
|
@@ -216,7 +216,8 @@ export function createSync({ dshHome, userHome, profileName = 'desktop', transpo
|
|
|
216
216
|
}
|
|
217
217
|
catch (error) {
|
|
218
218
|
appendHistory(paths.history, { at: new Date().toISOString(), action: 'backup', ok: false, ms: Date.now() - started });
|
|
219
|
-
|
|
219
|
+
const code = error?.code ?? 'E_UPLOAD_FAILED';
|
|
220
|
+
return { ok: false, code, detail: error.message };
|
|
220
221
|
}
|
|
221
222
|
finally {
|
|
222
223
|
releaseLock({ lockPath: paths.lock });
|
package/package.json
CHANGED