ccman 3.0.16 → 3.0.17

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.
Files changed (2) hide show
  1. package/dist/index.js +37 -34
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@ var init_package = __esm({
39
39
  "../core/package.json"() {
40
40
  package_default = {
41
41
  name: "@ccman/core",
42
- version: "3.0.16",
42
+ version: "3.0.17",
43
43
  type: "module",
44
44
  description: "Core business logic for ccman",
45
45
  main: "./dist/index.js",
@@ -16083,32 +16083,10 @@ function createWebDAVClient(config) {
16083
16083
  async function testWebDAVConnection(config) {
16084
16084
  try {
16085
16085
  const client = createWebDAVClient(config);
16086
- try {
16087
- await client.exists("/");
16088
- return true;
16089
- } catch (error1) {
16090
- console.log("\u65B9\u6CD51\u5931\u8D25\uFF0C\u5C1D\u8BD5\u65B9\u6CD52:", error1);
16091
- try {
16092
- await client.getDirectoryContents("/");
16093
- return true;
16094
- } catch (error2) {
16095
- console.log("\u65B9\u6CD52\u5931\u8D25\uFF0C\u5C1D\u8BD5\u65B9\u6CD53:", error2);
16096
- try {
16097
- const testDir = "/.ccman-test";
16098
- await client.createDirectory(testDir);
16099
- try {
16100
- await client.deleteFile(testDir);
16101
- } catch (e2) {
16102
- }
16103
- return true;
16104
- } catch (error3) {
16105
- console.error("\u6240\u6709\u6D4B\u8BD5\u65B9\u6CD5\u90FD\u5931\u8D25");
16106
- throw error3;
16107
- }
16108
- }
16109
- }
16086
+ await client.exists("/");
16087
+ return true;
16110
16088
  } catch (error) {
16111
- console.error("WebDAV \u8FDE\u63A5\u5931\u8D25:", error);
16089
+ console.error("WebDAV \u8FDE\u63A5\u5931\u8D25:", error.message);
16112
16090
  return false;
16113
16091
  }
16114
16092
  }
@@ -16134,20 +16112,45 @@ async function ensureDirectory(config, dirPath) {
16134
16112
  return false;
16135
16113
  }
16136
16114
  }
16115
+ function isPathNotFoundError(error) {
16116
+ const msg = error.message.toLowerCase();
16117
+ return msg.includes("404") || msg.includes("409") || msg.includes("not found") || msg.includes("conflict");
16118
+ }
16137
16119
  async function uploadToWebDAV(config, filename, data) {
16138
16120
  const client = createWebDAVClient(config);
16139
16121
  const remoteDir = normalizePath(config.remoteDir || "/");
16140
16122
  const fullPath = joinPath(remoteDir, filename);
16141
16123
  try {
16142
- const dirPath = fullPath.substring(0, fullPath.lastIndexOf("/"));
16143
- if (dirPath && dirPath !== "/") {
16144
- await ensureDirectory(config, dirPath);
16124
+ await client.putFileContents(fullPath, data, { overwrite: true });
16125
+ } catch (firstError) {
16126
+ if (isPathNotFoundError(firstError)) {
16127
+ const dirPath = fullPath.substring(0, fullPath.lastIndexOf("/"));
16128
+ if (dirPath && dirPath !== "/") {
16129
+ await ensureDirectory(config, dirPath);
16130
+ await client.putFileContents(fullPath, data, { overwrite: true });
16131
+ } else {
16132
+ throw firstError;
16133
+ }
16134
+ } else {
16135
+ throw firstError;
16145
16136
  }
16146
- await client.putFileContents(fullPath, data, {
16147
- overwrite: true
16148
- });
16149
- } catch (error) {
16150
- throw new Error(`\u4E0A\u4F20\u5931\u8D25: ${error.message}`);
16137
+ }
16138
+ try {
16139
+ const exists2 = await client.exists(fullPath);
16140
+ if (!exists2) {
16141
+ throw new Error(`\u6587\u4EF6\u4E0A\u4F20\u540E\u672A\u5728\u670D\u52A1\u5668\u4E0A\u627E\u5230: ${fullPath}`);
16142
+ }
16143
+ } catch (verifyError) {
16144
+ const errorMsg = verifyError.message;
16145
+ if (errorMsg.includes("multistatus") || errorMsg.includes("Invalid response")) {
16146
+ throw new Error(`WebDAV \u914D\u7F6E\u9519\u8BEF\uFF0C\u8BF7\u68C0\u67E5\uFF1A
16147
+ 1. URL \u662F\u5426\u4E3A WebDAV \u7AEF\u70B9\uFF08\u4E0D\u662F\u7F51\u9875\u5730\u5740\uFF09
16148
+ 2. \u7528\u6237\u540D\u548C\u5BC6\u7801\u662F\u5426\u6B63\u786E
16149
+ 3. \u8BA4\u8BC1\u7C7B\u578B\u662F\u5426\u5339\u914D
16150
+
16151
+ \u8BE6\u7EC6\uFF1A${errorMsg}`);
16152
+ }
16153
+ throw verifyError;
16151
16154
  }
16152
16155
  }
16153
16156
  async function downloadFromWebDAV(config, filename) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccman",
3
- "version": "3.0.16",
3
+ "version": "3.0.17",
4
4
  "description": "Manage Codex and Claude Code API service provider configurations",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {