jlcodes99/cockpit-tools · error

settings.webdav.errors.notEnabled

settings.webdav.errors.notEnabled

Error message

请先启用 WebDAV 同步

What it means

Guard in SettingsWebdavSyncSection.handleUploadNow: persistSettings() ran first, then savedSettings.enabled was false — WebDAV sync is configured but not switched on, so an immediate upload makes no sense. The i18n error settings.webdav.errors.notEnabled ('请先启用 WebDAV 同步') is thrown to stop the upload before any network call.

Source

Thrown at src/components/SettingsWebdavSyncSection.tsx:298

        }),
      });
    } finally {
      setTesting(false);
    }
  }, [clearPassword, passwordInput, remoteDir, url, username, persistSettings, loadRemoteFiles, t]);

  const handleUploadNow = useCallback(async () => {
    setUploading(true);
    setFeedback({
      tone: 'loading',
      text: t('settings.webdav.feedback.uploading', {
        defaultValue: '正在生成并上传备份...',
      }),
    });
    try {
      const savedSettings = await persistSettings();
      if (!savedSettings.enabled) {
        throw new Error(t('settings.webdav.errors.notEnabled', {
          defaultValue: '请先启用 WebDAV 同步',
        }));
      }
      const backupSettings = await getAutoBackupSettings();
      const backup = await createManagedBackup({
        trigger: 'manual',
        selection: getSelectionFromAutoBackupSettings(backupSettings),
        retentionDays: backupSettings.retention_days,
        markAsLastRun: true,
      });
      const result = await uploadAutoBackupToWebdav(backup.file_name);
      await loadSettings();
      setFeedback({
        tone: 'success',
        text: t('settings.webdav.feedback.uploadSuccess', {
          count: result.uploaded_files.length,
          deleted: result.deleted_files.length,
          defaultValue: '已上传 {{count}} 个文件,清理 {{deleted}} 个远端过期备份',

View on GitHub (pinned to 1ed8b77992)

Solutions

  1. Enable the WebDAV sync toggle in settings, then click upload again
  2. Verify persistSettings actually persisted the enabled flag before the upload path reads it
  3. Disable/grey out the upload button while sync is off to avoid hitting this path
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/components/SettingsWebdavSyncSection.tsx:298 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05). Data as JSON: /api/errors/78cb34e059930c16. Report an issue: GitHub.