zen-fs-config 0.6.1 → 0.6.3
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.
- package/dist/index.d.mts +58 -1
- package/dist/index.d.ts +58 -1
- package/dist/index.js +460 -209
- package/dist/index.mjs +460 -209
- package/dist/zen-fs-config.js +456 -208
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -952,6 +952,22 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
952
952
|
private readonly pollIntervalMs?;
|
|
953
953
|
/** Tombstone cache — avoids redundant reads within a single flush() cycle. */
|
|
954
954
|
private tombstoneCache;
|
|
955
|
+
/**
|
|
956
|
+
* 墓碑存在期间被排除在同步之外的路径。
|
|
957
|
+
*
|
|
958
|
+
* 远端副本可能仍残留被删路径(哪怕只剩 `.keep` / `.keep.mtime` 占位)。
|
|
959
|
+
* 若同步照常进行,这类残留会被当成"远端新增"再拉回本地,造成空壳复活。
|
|
960
|
+
* 这些路径改由 processTombstones 主动删除,直到所有副本确认不存在、
|
|
961
|
+
* 墓碑被 GC 之后才恢复同步。
|
|
962
|
+
*/
|
|
963
|
+
private readonly tombstoneExcludePrefixes;
|
|
964
|
+
private readonly syncFilter;
|
|
965
|
+
/**
|
|
966
|
+
* 本轮 processTombstones 中,各副本对墓碑路径"已确认不存在"的结果。
|
|
967
|
+
* 目录类路径用 exists() 复核;`.mtime` 侧车对部分后端不可见,只能用
|
|
968
|
+
* unlink() 是否成功来判定。
|
|
969
|
+
*/
|
|
970
|
+
private readonly tombstoneConfirmations;
|
|
955
971
|
/** Per-backend sync state (successful pairs + connect failures). */
|
|
956
972
|
private backendStates;
|
|
957
973
|
/** Last known backend descriptors, for the synchronous unified handle API. */
|
|
@@ -1000,6 +1016,13 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
1000
1016
|
* Results are cached within a flush() cycle to avoid redundant reads.
|
|
1001
1017
|
*/
|
|
1002
1018
|
private readTombstones;
|
|
1019
|
+
/**
|
|
1020
|
+
* 把当前墓碑路径同步到同步排除表。
|
|
1021
|
+
*
|
|
1022
|
+
* 排除表与各同步对共享同一个数组实例(zen-fs-sync 在每次检测时实时读取
|
|
1023
|
+
* `filter.excludePrefixes`),所以这里原地更新即可生效。
|
|
1024
|
+
*/
|
|
1025
|
+
private refreshSyncExclusions;
|
|
1003
1026
|
/** Invalidate the tombstone cache — call after tombstones are modified. */
|
|
1004
1027
|
private invalidateTombstoneCache;
|
|
1005
1028
|
/**
|
|
@@ -1013,6 +1036,24 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
1013
1036
|
* effectively free for them.
|
|
1014
1037
|
*/
|
|
1015
1038
|
private processTombstones;
|
|
1039
|
+
/**
|
|
1040
|
+
* 删除墓碑目标在某个后端上的全部残留。
|
|
1041
|
+
*
|
|
1042
|
+
* 目录不能直接 unlink(会抛 EISDIR)。旧实现把这个异常当成"已被并发删除"
|
|
1043
|
+
* 而继续推进确认,墓碑随后被 GC;但副本上的占位目录仍然存在,下一次同步
|
|
1044
|
+
* 就把它当作远端内容拉回本地,形成空壳复活。
|
|
1045
|
+
*
|
|
1046
|
+
* 这里按树清理:
|
|
1047
|
+
* 1. 强制删掉 `.keep` / `.keep.mtime` 占位(部分后端把 `.keep` 隐藏在索引里,
|
|
1048
|
+
* readdir 看不到,只能按路径直接删);
|
|
1049
|
+
* 2. 递归清理可见子项;
|
|
1050
|
+
* 3. rmdir(后端不支持目录时退回 unlink)。
|
|
1051
|
+
*
|
|
1052
|
+
* @returns 是否确认该路径已不存在;清理失败返回 false,墓碑必须保留。
|
|
1053
|
+
*/
|
|
1054
|
+
private purgePathOnBackend;
|
|
1055
|
+
/** 后端无关的存在性判断:优先 exists(),否则退化为 stat()。 */
|
|
1056
|
+
private pathExistsOnBackend;
|
|
1016
1057
|
/**
|
|
1017
1058
|
* Safe existence check — returns false on any error instead of throwing.
|
|
1018
1059
|
* Used by processTombstones to avoid unnecessary unlink() calls.
|
|
@@ -1071,9 +1112,25 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
1071
1112
|
*/
|
|
1072
1113
|
startBackgroundSync(): void;
|
|
1073
1114
|
/**
|
|
1074
|
-
* After sync: mark each tombstone as confirmed by
|
|
1115
|
+
* After sync: mark each tombstone as confirmed by replicas where the target
|
|
1116
|
+
* path was actually verified absent.
|
|
1117
|
+
*
|
|
1118
|
+
* 旧实现把所有副本无条件写进 confirmedBy,只要有一轮同步跑过就认为
|
|
1119
|
+
* "所有副本都删干净了"。但副本可能因为网络/后端限制删除失败,或只剩
|
|
1120
|
+
* `.keep` / `.keep.mtime` 占位目录;墓碑一旦被 GC,下一轮同步就把残留
|
|
1121
|
+
* 当作远端内容拉回本地。现在只确认 processTombstones 本轮真正清干净的副本。
|
|
1075
1122
|
*/
|
|
1076
1123
|
private updateTombstoneConfirmations;
|
|
1124
|
+
/**
|
|
1125
|
+
* 墓碑路径是否已在所有副本上确认不存在。
|
|
1126
|
+
*
|
|
1127
|
+
* `.mtime` 侧车与 `.keep` 占位对部分后端不可见(`exists()` 恒为 false),
|
|
1128
|
+
* 因此只能相信本轮 `processTombstones` 的 unlink 结果;其余路径在 GC 前
|
|
1129
|
+
* 现场复核一次,避免"确认之后副本又把残留带了回来"。
|
|
1130
|
+
*
|
|
1131
|
+
* 任一位置仍存在就返回 false —— 墓碑必须保留,直到真正删干净。
|
|
1132
|
+
*/
|
|
1133
|
+
private allReplicasConfirmAbsent;
|
|
1077
1134
|
/**
|
|
1078
1135
|
* GC: remove tombstones where all backends in backends.json have confirmed.
|
|
1079
1136
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -952,6 +952,22 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
952
952
|
private readonly pollIntervalMs?;
|
|
953
953
|
/** Tombstone cache — avoids redundant reads within a single flush() cycle. */
|
|
954
954
|
private tombstoneCache;
|
|
955
|
+
/**
|
|
956
|
+
* 墓碑存在期间被排除在同步之外的路径。
|
|
957
|
+
*
|
|
958
|
+
* 远端副本可能仍残留被删路径(哪怕只剩 `.keep` / `.keep.mtime` 占位)。
|
|
959
|
+
* 若同步照常进行,这类残留会被当成"远端新增"再拉回本地,造成空壳复活。
|
|
960
|
+
* 这些路径改由 processTombstones 主动删除,直到所有副本确认不存在、
|
|
961
|
+
* 墓碑被 GC 之后才恢复同步。
|
|
962
|
+
*/
|
|
963
|
+
private readonly tombstoneExcludePrefixes;
|
|
964
|
+
private readonly syncFilter;
|
|
965
|
+
/**
|
|
966
|
+
* 本轮 processTombstones 中,各副本对墓碑路径"已确认不存在"的结果。
|
|
967
|
+
* 目录类路径用 exists() 复核;`.mtime` 侧车对部分后端不可见,只能用
|
|
968
|
+
* unlink() 是否成功来判定。
|
|
969
|
+
*/
|
|
970
|
+
private readonly tombstoneConfirmations;
|
|
955
971
|
/** Per-backend sync state (successful pairs + connect failures). */
|
|
956
972
|
private backendStates;
|
|
957
973
|
/** Last known backend descriptors, for the synchronous unified handle API. */
|
|
@@ -1000,6 +1016,13 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
1000
1016
|
* Results are cached within a flush() cycle to avoid redundant reads.
|
|
1001
1017
|
*/
|
|
1002
1018
|
private readTombstones;
|
|
1019
|
+
/**
|
|
1020
|
+
* 把当前墓碑路径同步到同步排除表。
|
|
1021
|
+
*
|
|
1022
|
+
* 排除表与各同步对共享同一个数组实例(zen-fs-sync 在每次检测时实时读取
|
|
1023
|
+
* `filter.excludePrefixes`),所以这里原地更新即可生效。
|
|
1024
|
+
*/
|
|
1025
|
+
private refreshSyncExclusions;
|
|
1003
1026
|
/** Invalidate the tombstone cache — call after tombstones are modified. */
|
|
1004
1027
|
private invalidateTombstoneCache;
|
|
1005
1028
|
/**
|
|
@@ -1013,6 +1036,24 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
1013
1036
|
* effectively free for them.
|
|
1014
1037
|
*/
|
|
1015
1038
|
private processTombstones;
|
|
1039
|
+
/**
|
|
1040
|
+
* 删除墓碑目标在某个后端上的全部残留。
|
|
1041
|
+
*
|
|
1042
|
+
* 目录不能直接 unlink(会抛 EISDIR)。旧实现把这个异常当成"已被并发删除"
|
|
1043
|
+
* 而继续推进确认,墓碑随后被 GC;但副本上的占位目录仍然存在,下一次同步
|
|
1044
|
+
* 就把它当作远端内容拉回本地,形成空壳复活。
|
|
1045
|
+
*
|
|
1046
|
+
* 这里按树清理:
|
|
1047
|
+
* 1. 强制删掉 `.keep` / `.keep.mtime` 占位(部分后端把 `.keep` 隐藏在索引里,
|
|
1048
|
+
* readdir 看不到,只能按路径直接删);
|
|
1049
|
+
* 2. 递归清理可见子项;
|
|
1050
|
+
* 3. rmdir(后端不支持目录时退回 unlink)。
|
|
1051
|
+
*
|
|
1052
|
+
* @returns 是否确认该路径已不存在;清理失败返回 false,墓碑必须保留。
|
|
1053
|
+
*/
|
|
1054
|
+
private purgePathOnBackend;
|
|
1055
|
+
/** 后端无关的存在性判断:优先 exists(),否则退化为 stat()。 */
|
|
1056
|
+
private pathExistsOnBackend;
|
|
1016
1057
|
/**
|
|
1017
1058
|
* Safe existence check — returns false on any error instead of throwing.
|
|
1018
1059
|
* Used by processTombstones to avoid unnecessary unlink() calls.
|
|
@@ -1071,9 +1112,25 @@ declare class ConfigRepo implements IConfigRepo {
|
|
|
1071
1112
|
*/
|
|
1072
1113
|
startBackgroundSync(): void;
|
|
1073
1114
|
/**
|
|
1074
|
-
* After sync: mark each tombstone as confirmed by
|
|
1115
|
+
* After sync: mark each tombstone as confirmed by replicas where the target
|
|
1116
|
+
* path was actually verified absent.
|
|
1117
|
+
*
|
|
1118
|
+
* 旧实现把所有副本无条件写进 confirmedBy,只要有一轮同步跑过就认为
|
|
1119
|
+
* "所有副本都删干净了"。但副本可能因为网络/后端限制删除失败,或只剩
|
|
1120
|
+
* `.keep` / `.keep.mtime` 占位目录;墓碑一旦被 GC,下一轮同步就把残留
|
|
1121
|
+
* 当作远端内容拉回本地。现在只确认 processTombstones 本轮真正清干净的副本。
|
|
1075
1122
|
*/
|
|
1076
1123
|
private updateTombstoneConfirmations;
|
|
1124
|
+
/**
|
|
1125
|
+
* 墓碑路径是否已在所有副本上确认不存在。
|
|
1126
|
+
*
|
|
1127
|
+
* `.mtime` 侧车与 `.keep` 占位对部分后端不可见(`exists()` 恒为 false),
|
|
1128
|
+
* 因此只能相信本轮 `processTombstones` 的 unlink 结果;其余路径在 GC 前
|
|
1129
|
+
* 现场复核一次,避免"确认之后副本又把残留带了回来"。
|
|
1130
|
+
*
|
|
1131
|
+
* 任一位置仍存在就返回 false —— 墓碑必须保留,直到真正删干净。
|
|
1132
|
+
*/
|
|
1133
|
+
private allReplicasConfirmAbsent;
|
|
1077
1134
|
/**
|
|
1078
1135
|
* GC: remove tombstones where all backends in backends.json have confirmed.
|
|
1079
1136
|
*
|