Fix Vencloud syncing
Some checks failed
Build Branches / Build Equicord (push) Has been skipped
Sync to Codeberg / codeberg (push) Has been skipped
Test / Test (push) Failing after 4s

This commit is contained in:
thororen 2026-10-03 23:34:54 -04:00
parent ead6a60a70
commit 09ccf0878d
No known key found for this signature in database

View file

@ -144,6 +144,22 @@ function handleAuthFailure() {
Settings.cloud.authenticated = false;
}
async function isV1Reachable() {
try {
const res = await fetch(new URL("/v1/settings", getCloudUrl()), {
method: "GET",
headers: {
Authorization: await getCloudAuth(),
Accept: "application/octet-stream",
"If-None-Match": Settings.cloud.settingsSyncVersion.toString(),
},
});
return res.ok || res.status === 304 || res.status === 404;
} catch {
return false;
}
}
async function doSyncV2(uploads: SyncRequest["uploads"], clientManifest: ManifestEntry[]): Promise<SyncResponse | null> {
let res: Response;
try {
@ -156,7 +172,12 @@ async function doSyncV2(uploads: SyncRequest["uploads"], clientManifest: Manifes
body: JSON.stringify({ client_manifest: clientManifest, uploads } satisfies SyncRequest),
});
} catch (e) {
logger.error("v2 sync network error, will retry next sync", e);
if (await isV1Reachable()) {
logger.info("v2 sync request failed but v1 is reachable, falling back to v1", e);
await setApiVersion("v1");
} else {
logger.error("v2 sync network error, will retry next sync", e);
}
return null;
}