Fix Clouddrop IP folders and concurrent log creation verification
CI / verify (push) Canceled after 0s

This commit is contained in:
Sucukdeluxe committed 2026-10-15 04:33:52 +02:00
1 parent 345870dcc9
commit bc4a718210
3 files changed
+22 -17

No files matched your search

+1 -1
View File
@@ -280,7 +280,7 @@ You can always install manually from the [GitHub releases page](https://github.c
## Clouddrop log sync ## Clouddrop log sync
Settings → Logs & Support includes an optional Clouddrop connection for upload logs. Enter an unrestricted Clouddrop API key and select **Verify and enable**. Verification creates an empty test file in a folder named after the device's public IP address; ipify provides the public IP. The key is stored using the operating system's credential encryption. Settings → Logs & Support includes an optional Clouddrop connection for upload logs. Enter an unrestricted Clouddrop API key and select **Verify and enable**. Verification creates an empty test file in a folder named after the device's public IP address; ipify provides the public IP. IPv4 is preferred, with readable IPv6 as a fallback. The key is stored using the operating system's credential encryption. Multiple instances can use the same key; each writes its own files, including when instances share a public IP.
New successful upload entries for hosts with file logging enabled are synchronized automatically as TXT files. The single-file, daily and per-session log modes apply. Files have unique suffixes so separate instances using the same key do not overwrite one another. Large logs are split into separate files before they reach the text API size limit. Existing local log contents are not imported automatically. New successful upload entries for hosts with file logging enabled are synchronized automatically as TXT files. The single-file, daily and per-session log modes apply. Files have unique suffixes so separate instances using the same key do not overwrite one another. Large logs are split into separate files before they reach the text API size limit. Existing local log contents are not imported automatically.
+20 -15
View File
@@ -61,15 +61,20 @@ class ClouddropLogApi {
|| Number(expires) <= Date.now() || !/^[a-f0-9]{64}$/.test(signature || '') || extra !== undefined) { || Number(expires) <= Date.now() || !/^[a-f0-9]{64}$/.test(signature || '') || extra !== undefined) {
throw new CloudLogError('INVALID_RESPONSE'); throw new CloudLogError('INVALID_RESPONSE');
} }
const response = await this.request('https://api64.ipify.org?format=json', { for (const endpoint of ['https://api.ipify.org?format=json', 'https://api64.ipify.org?format=json']) {
signal, maxRedirections: 0, headersTimeout: 15000, bodyTimeout: 15000, try {
headers: { Accept: 'application/json' } const response = await this.request(endpoint, {
}); signal, maxRedirections: 0, headersTimeout: 10000, bodyTimeout: 10000,
const text = await response.body.text(); headers: { Accept: 'application/json' }
let ip; });
try { ip = JSON.parse(text).ip; } catch {} const text = await response.body.text();
if (response.statusCode !== 200 || !isIP(ip || '')) throw new CloudLogError('IP_UNAVAILABLE'); const ip = JSON.parse(text).ip;
return { accountId, ip, folderName: ip.replaceAll(':', '_') }; if (response.statusCode === 200 && isIP(ip || '')) return { accountId, ip, folderName: ip };
} catch {
if (signal?.aborted) throw new CloudLogError('IP_UNAVAILABLE');
}
}
throw new CloudLogError('IP_UNAVAILABLE');
} }
async ensureFolder(name, signal) { async ensureFolder(name, signal) {
@@ -91,6 +96,7 @@ class ClouddropLogApi {
} }
async createFile(folderId, name, id, signal) { async createFile(folderId, name, id, signal) {
const verificationRoute = `/check-duplicate?parent=${encodeURIComponent(folderId)}&filename=${encodeURIComponent(name)}`;
let created; let created;
try { try {
created = await this.call('/create-file', { created = await this.call('/create-file', {
@@ -99,14 +105,13 @@ class ClouddropLogApi {
}); });
} catch (error) { } catch (error) {
if (error.status !== 409) throw error; if (error.status !== 409) throw error;
const existing = await this.call(`/files?parent=${encodeURIComponent(folderId)}&limit=2500&sync=${encodeURIComponent(id)}`, { signal }); const existing = await this.call(verificationRoute, { signal });
const file = existing.files?.find(item => item.filename === name && item.parentId === folderId && !item.isFolder); if (!existing.exists || !existing.existingId) throw error;
if (!file) throw error; created = { id: existing.existingId, filename: name };
created = { id: file.id, filename: file.filename };
} }
if (!created.id || created.filename !== name) throw new CloudLogError('INVALID_RESPONSE'); if (!created.id || created.filename !== name) throw new CloudLogError('INVALID_RESPONSE');
const listing = await this.call(`/files?parent=${encodeURIComponent(folderId)}&limit=2500&sync=${encodeURIComponent(id)}`, { signal }); const verification = await this.call(verificationRoute, { signal });
if (!Array.isArray(listing.files) || !listing.files.some(file => file.id === created.id && file.parentId === folderId)) { if (verification.exists !== true || verification.existingId !== created.id) {
throw new CloudLogError('UNRESTRICTED_KEY_REQUIRED'); throw new CloudLogError('UNRESTRICTED_KEY_REQUIRED');
} }
return String(created.id); return String(created.id);
+1 -1
View File
@@ -6409,7 +6409,7 @@ function renderCloudLogStatus(status) {
if (!status || !document.getElementById('cloudLogPhase')) return; if (!status || !document.getElementById('cloudLogPhase')) return;
const phases = { disabled: 'Inaktiv', checking: 'Verbindung wird geprüft…', ready: 'Aktiv', syncing: 'Wird synchronisiert…', error: 'Synchronisierung fehlgeschlagen' }; const phases = { disabled: 'Inaktiv', checking: 'Verbindung wird geprüft…', ready: 'Aktiv', syncing: 'Wird synchronisiert…', error: 'Synchronisierung fehlgeschlagen' };
document.getElementById('cloudLogPhase').textContent = localizeUiText(phases[status.phase] || phases.disabled); document.getElementById('cloudLogPhase').textContent = localizeUiText(phases[status.phase] || phases.disabled);
document.getElementById('cloudLogIp').textContent = status.ip ? status.ip.replaceAll(':', '_') : '—'; document.getElementById('cloudLogIp').textContent = status.ip || '—';
document.getElementById('cloudLogLastSync').textContent = status.lastSyncedAt document.getElementById('cloudLogLastSync').textContent = status.lastSyncedAt
? new Date(status.lastSyncedAt).toLocaleString(getUiLocale()) : localizeUiText('Noch nicht synchronisiert'); ? new Date(status.lastSyncedAt).toLocaleString(getUiLocale()) : localizeUiText('Noch nicht synchronisiert');
document.getElementById('cloudLogPending').textContent = (Number(status.pendingFiles) || 0).toLocaleString(getUiLocale()); document.getElementById('cloudLogPending').textContent = (Number(status.pendingFiles) || 0).toLocaleString(getUiLocale());