karin-plugin-qgroup-file2openlist 0.0.28 → 0.0.30

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.
@@ -6,12 +6,12 @@ import "../chunk-PBBZ5KAD.js";
6
6
  import "../chunk-QB3GSENE.js";
7
7
  import {
8
8
  handleGroupFileUploadedAutoBackup
9
- } from "../chunk-ZXZMBJN3.js";
10
- import "../chunk-AAKFRFSO.js";
9
+ } from "../chunk-KB5N77CR.js";
10
+ import "../chunk-YQPHJTEB.js";
11
11
  import {
12
12
  backupOpenListToOpenListCore,
13
13
  formatErrorMessage
14
- } from "../chunk-HSFFULJR.js";
14
+ } from "../chunk-NWUWEQLH.js";
15
15
  import {
16
16
  config
17
17
  } from "../chunk-DA4U55JC.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  exportGroupFilesToDisk,
3
3
  syncGroupFilesToOpenListCore
4
- } from "../chunk-ZXZMBJN3.js";
5
- import "../chunk-AAKFRFSO.js";
4
+ } from "../chunk-KB5N77CR.js";
5
+ import "../chunk-YQPHJTEB.js";
6
6
  import {
7
7
  formatErrorMessage,
8
8
  normalizePosixPath
9
- } from "../chunk-HSFFULJR.js";
9
+ } from "../chunk-NWUWEQLH.js";
10
10
  import {
11
11
  config
12
12
  } from "../chunk-DA4U55JC.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  handleGroupSyncConfigCommand
3
- } from "../chunk-H2TAMQ7I.js";
4
- import "../chunk-ZXZMBJN3.js";
5
- import "../chunk-AAKFRFSO.js";
6
- import "../chunk-HSFFULJR.js";
3
+ } from "../chunk-CE6KVBH4.js";
4
+ import "../chunk-KB5N77CR.js";
5
+ import "../chunk-YQPHJTEB.js";
6
+ import "../chunk-NWUWEQLH.js";
7
7
  import "../chunk-DA4U55JC.js";
8
8
  import "../chunk-IZS467MR.js";
9
9
 
@@ -5,7 +5,7 @@ import {
5
5
  resolveOpltMapping,
6
6
  withOpltUser,
7
7
  writeOpltData
8
- } from "../chunk-GAVQ23XT.js";
8
+ } from "../chunk-VVJJTF2N.js";
9
9
  import {
10
10
  buildActionCard,
11
11
  replyImages
@@ -20,7 +20,7 @@ import {
20
20
  normalizePosixPath,
21
21
  readJsonSafe,
22
22
  writeJsonSafe
23
- } from "../chunk-HSFFULJR.js";
23
+ } from "../chunk-NWUWEQLH.js";
24
24
  import {
25
25
  config
26
26
  } from "../chunk-DA4U55JC.js";
@@ -4,14 +4,14 @@ import {
4
4
  import "../chunk-QB3GSENE.js";
5
5
  import {
6
6
  readGroupSyncState
7
- } from "../chunk-AAKFRFSO.js";
7
+ } from "../chunk-YQPHJTEB.js";
8
8
  import {
9
9
  backupOpenListToOpenListCore,
10
10
  formatErrorMessage,
11
11
  normalizePosixPath,
12
12
  readJsonSafe,
13
13
  writeJsonSafe
14
- } from "../chunk-HSFFULJR.js";
14
+ } from "../chunk-NWUWEQLH.js";
15
15
  import "../chunk-DA4U55JC.js";
16
16
  import {
17
17
  dir
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  runNightlyOpltBackup
3
- } from "../chunk-GAVQ23XT.js";
3
+ } from "../chunk-VVJJTF2N.js";
4
4
  import {
5
5
  runNightlyGroupBackup
6
- } from "../chunk-H2TAMQ7I.js";
7
- import "../chunk-ZXZMBJN3.js";
8
- import "../chunk-AAKFRFSO.js";
9
- import "../chunk-HSFFULJR.js";
6
+ } from "../chunk-CE6KVBH4.js";
7
+ import "../chunk-KB5N77CR.js";
8
+ import "../chunk-YQPHJTEB.js";
9
+ import "../chunk-NWUWEQLH.js";
10
10
  import {
11
11
  config
12
12
  } from "../chunk-DA4U55JC.js";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  syncGroupFilesToOpenListCore
3
- } from "./chunk-ZXZMBJN3.js";
3
+ } from "./chunk-KB5N77CR.js";
4
4
  import {
5
5
  normalizePosixPath,
6
6
  readJsonSafe,
7
7
  writeJsonSafe
8
- } from "./chunk-HSFFULJR.js";
8
+ } from "./chunk-NWUWEQLH.js";
9
9
  import {
10
10
  config
11
11
  } from "./chunk-DA4U55JC.js";
@@ -2,7 +2,7 @@ import {
2
2
  readGroupSyncState,
3
3
  withGroupSyncLock,
4
4
  writeGroupSyncState
5
- } from "./chunk-AAKFRFSO.js";
5
+ } from "./chunk-YQPHJTEB.js";
6
6
  import {
7
7
  buildOpenListAuthHeader,
8
8
  buildOpenListDavBaseUrl,
@@ -16,7 +16,7 @@ import {
16
16
  runWithConcurrency,
17
17
  safePathSegment,
18
18
  webdavHeadExists
19
- } from "./chunk-HSFFULJR.js";
19
+ } from "./chunk-NWUWEQLH.js";
20
20
  import {
21
21
  config,
22
22
  time
@@ -718,6 +718,7 @@ var isRetryableWebDavError = (error) => {
718
718
  return /ECONNRESET|ETIMEDOUT|EAI_AGAIN|ENOTFOUND|ECONNREFUSED|UND_ERR|socket hang up/i.test(msg);
719
719
  };
720
720
  var webdavMkcolOk = (status) => status === 201 || status === 405;
721
+ var existsCheckModeByDavBaseUrl = /* @__PURE__ */ new Map();
721
722
  var webdavPropfindListEntries = async (params) => {
722
723
  const { davBaseUrl, auth, dirPath, timeoutMs } = params;
723
724
  const controller = new AbortController();
@@ -787,15 +788,79 @@ var webdavHeadExists = async (params) => {
787
788
  const { davBaseUrl, auth, filePath, timeoutMs } = params;
788
789
  const controller = new AbortController();
789
790
  const timer = setTimeout(() => controller.abort(), timeoutMs);
791
+ const propfindExists = async () => {
792
+ const url = `${davBaseUrl}${encodePathForUrl(filePath)}`;
793
+ const body = `<?xml version="1.0" encoding="utf-8" ?>
794
+ <d:propfind xmlns:d="DAV:">
795
+ <d:prop>
796
+ <d:resourcetype />
797
+ </d:prop>
798
+ </d:propfind>`;
799
+ const res = await fetch(url, {
800
+ method: "PROPFIND",
801
+ headers: {
802
+ Authorization: auth,
803
+ Depth: "0",
804
+ "Content-Type": "application/xml; charset=utf-8"
805
+ },
806
+ body,
807
+ redirect: "follow",
808
+ signal: controller.signal
809
+ });
810
+ if (res.ok) {
811
+ try {
812
+ await res.body?.cancel();
813
+ } catch {
814
+ }
815
+ return true;
816
+ }
817
+ try {
818
+ await res.body?.cancel();
819
+ } catch {
820
+ }
821
+ return false;
822
+ };
823
+ const key = davBaseUrl;
824
+ const mode = existsCheckModeByDavBaseUrl.get(key) ?? "head";
790
825
  try {
791
826
  const url = `${davBaseUrl}${encodePathForUrl(filePath)}`;
827
+ if (mode === "propfind") {
828
+ return await propfindExists();
829
+ }
792
830
  const res = await fetch(url, {
793
831
  method: "HEAD",
794
832
  headers: { Authorization: auth },
795
833
  redirect: "follow",
796
834
  signal: controller.signal
797
835
  });
798
- return res.ok;
836
+ if (res.ok) {
837
+ try {
838
+ await res.body?.cancel();
839
+ } catch {
840
+ }
841
+ return true;
842
+ }
843
+ if (res.status === 404) {
844
+ try {
845
+ await res.body?.cancel();
846
+ } catch {
847
+ }
848
+ return false;
849
+ }
850
+ if (res.status === 403 || res.status === 405 || res.status === 501) {
851
+ try {
852
+ await res.body?.cancel();
853
+ } catch {
854
+ }
855
+ const ok = await propfindExists();
856
+ existsCheckModeByDavBaseUrl.set(key, "propfind");
857
+ return ok;
858
+ }
859
+ try {
860
+ await res.body?.cancel();
861
+ } catch {
862
+ }
863
+ return await propfindExists();
799
864
  } catch {
800
865
  return false;
801
866
  } finally {
@@ -4,7 +4,7 @@ import {
4
4
  normalizePosixPath,
5
5
  readJsonSafe,
6
6
  writeJsonSafe
7
- } from "./chunk-HSFFULJR.js";
7
+ } from "./chunk-NWUWEQLH.js";
8
8
  import {
9
9
  config
10
10
  } from "./chunk-DA4U55JC.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  readJsonSafe,
3
3
  writeJsonSafe
4
- } from "./chunk-HSFFULJR.js";
4
+ } from "./chunk-NWUWEQLH.js";
5
5
  import {
6
6
  dir
7
7
  } from "./chunk-IZS467MR.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "karin-plugin-qgroup-file2openlist",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "author": "429",
5
5
  "type": "module",
6
6
  "description": "karin plugin for QGroupFile backup",