{"record":{"id":"78cb34e059930c16","repo":"jlcodes99/cockpit-tools","slug":"settings-webdav-errors-notenabled","errorCode":"settings.webdav.errors.notEnabled","errorMessage":"请先启用 WebDAV 同步","messagePattern":"请先启用 WebDAV 同步","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/components/SettingsWebdavSyncSection.tsx","lineNumber":298,"sourceCode":"        }),\n      });\n    } finally {\n      setTesting(false);\n    }\n  }, [clearPassword, passwordInput, remoteDir, url, username, persistSettings, loadRemoteFiles, t]);\n\n  const handleUploadNow = useCallback(async () => {\n    setUploading(true);\n    setFeedback({\n      tone: 'loading',\n      text: t('settings.webdav.feedback.uploading', {\n        defaultValue: '正在生成并上传备份...',\n      }),\n    });\n    try {\n      const savedSettings = await persistSettings();\n      if (!savedSettings.enabled) {\n        throw new Error(t('settings.webdav.errors.notEnabled', {\n          defaultValue: '请先启用 WebDAV 同步',\n        }));\n      }\n      const backupSettings = await getAutoBackupSettings();\n      const backup = await createManagedBackup({\n        trigger: 'manual',\n        selection: getSelectionFromAutoBackupSettings(backupSettings),\n        retentionDays: backupSettings.retention_days,\n        markAsLastRun: true,\n      });\n      const result = await uploadAutoBackupToWebdav(backup.file_name);\n      await loadSettings();\n      setFeedback({\n        tone: 'success',\n        text: t('settings.webdav.feedback.uploadSuccess', {\n          count: result.uploaded_files.length,\n          deleted: result.deleted_files.length,\n          defaultValue: '已上传 {{count}} 个文件，清理 {{deleted}} 个远端过期备份',","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/jlcodes99/cockpit-tools/blob/1ed8b77992d62ca81fabf744deb0839ad361d5bf/src/components/SettingsWebdavSyncSection.tsx#L280-L316","documentation":"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.","triggerScenarios":"Thrown at src/components/SettingsWebdavSyncSection.tsx:298 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Enable the WebDAV sync toggle in settings, then click upload again","Verify persistSettings actually persisted the enabled flag before the upload path reads it","Disable/grey out the upload button while sync is off to avoid hitting this path"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1ed8b77992d62ca81fabf744deb0839ad361d5bf","analyzedAt":"2026-09-05T09:51:41.178Z","contentChangedAt":"2026-09-05T09:51:41.178Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}