@rljson/fs-agent 0.2.2 → 0.2.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.
@@ -577,6 +577,8 @@ export declare class FsAgent {
577
577
  * @param conflicted - Paths edited here while away and changed elsewhere.
578
578
  * @param copies - Where each moved file went, `path → name`; a path the
579
579
  * join could not move has no entry.
580
+ * @param why - `away`: the machine joined the network; `ignore`: it sees
581
+ * paths again that its ignore list had left out.
580
582
  */
581
583
  private _signalJoinOutcome;
582
584
  /**
@@ -786,7 +788,10 @@ export declare class FsAgent {
786
788
  * followed to decide what to remove.
787
789
  * @param path - Where the node is to be written.
788
790
  * @param want - What the tree says should be there.
789
- * @returns Whether something had to be removed.
791
+ * @param relativePath - The path in the folder, when restoring into this
792
+ * node's own: an entry there this node ignores is never removed.
793
+ * @returns Whether the place is free for the node now; `false` when an
794
+ * entry this node ignores holds it.
790
795
  */
791
796
  /**
792
797
  * Whether a path the prune is about to delete is actually the expected file
@@ -801,6 +806,16 @@ export declare class FsAgent {
801
806
  * @returns Whether the entry must be kept.
802
807
  */
803
808
  private _isSameFileAsExpected;
809
+ /**
810
+ * Whether a restore leaves a node out: what this node does not see, it does
811
+ * not write into its folder — a directory with everything below it. Another
812
+ * node's version of such a path is carried in its edits, never put on its
813
+ * disk. Anywhere else a tree is just a tree.
814
+ * @param meta - The node's meta.
815
+ * @param isOwnRoot - Whether the restore writes into this node's folder.
816
+ * @returns True when the node is not to be written.
817
+ */
818
+ private _leavesOut;
804
819
  private _makeRoomFor;
805
820
  static _isInsideRoot(target: string, relativePath: string): boolean;
806
821
  private static _isImpossiblePath;
@@ -956,6 +971,26 @@ export declare class FsAgent {
956
971
  * restart the floors judge what is gone afresh, as before.
957
972
  */
958
973
  private _heldBack;
974
+ /**
975
+ * The own head's nodes at the paths this node does not see — see
976
+ * `fs-carry.ts`. Carried into every edit it authors; an apply neither writes
977
+ * nor deletes them. Empty while the head names nothing this node ignores.
978
+ */
979
+ private _carried;
980
+ /**
981
+ * Paths this node sees again since a pattern left its ignore list, whose
982
+ * version the own head holds is not in the folder yet. Carried until it is —
983
+ * see {@link FsAgent._uncover}.
984
+ */
985
+ private readonly _uncovered;
986
+ /** A restart found its ignore list changed, and `_uncover` has not run. */
987
+ private _uncoverDue;
988
+ /**
989
+ * The ignore list the state file records: the one the folder is in step
990
+ * with. It becomes the scanner's list once nothing a change of the list
991
+ * uncovered is still missing.
992
+ */
993
+ private _ignoreOnRecord;
959
994
  /** Every chain entry's stamp, as this node learned it. */
960
995
  private _stamps?;
961
996
  /** The route this agent syncs, once a sync started. */
@@ -1096,13 +1131,35 @@ export declare class FsAgent {
1096
1131
  * @returns The head, or `undefined`.
1097
1132
  */
1098
1133
  private _persistedHead;
1134
+ /**
1135
+ * The ignore list `.fsagent-state.json` records, if it records one — the
1136
+ * list the folder was in step with when this node last ran.
1137
+ * @returns The list, or `undefined`.
1138
+ */
1139
+ private _persistedIgnore;
1140
+ /**
1141
+ * `.fsagent-state.json`, read.
1142
+ * @returns What it holds, or `undefined` when it cannot be read.
1143
+ */
1144
+ private _persistedState;
1099
1145
  /**
1100
1146
  * Makes `head` this node's head, and remembers it across a restart.
1101
1147
  * @param head - The chain entry.
1102
1148
  * @param content - The tree it names, `path → blob`.
1149
+ * @param carried - Its nodes at the paths this node does not see.
1103
1150
  */
1104
1151
  private _setOwn;
1105
- /** Writes {@link AGENT_STATE_FILE}: the own head and the stamp epochs. */
1152
+ /**
1153
+ * What a head's tree holds at the paths this node does not see: those its
1154
+ * ignore list leaves out, and those it sees again and does not hold yet.
1155
+ * @param tree - The tree.
1156
+ * @returns The nodes, by path.
1157
+ */
1158
+ private _carriedOf;
1159
+ /**
1160
+ * Writes {@link AGENT_STATE_FILE}: the own head, the stamp epochs, and the
1161
+ * ignore list the folder is in step with.
1162
+ */
1106
1163
  private _writeState;
1107
1164
  /** The stamp epochs the state file holds, as written. */
1108
1165
  private _writtenEpochs;
@@ -1125,9 +1182,10 @@ export declare class FsAgent {
1125
1182
  */
1126
1183
  private _askForStamp;
1127
1184
  /**
1128
- * Authors an edit for the folder as `tree` describes it, if it moved past
1129
- * the own head and the edit is honest — see `planAuthoring`.
1130
- * @param tree - The folder, as just scanned.
1185
+ * Authors an edit for the folder as `scanned` describes it, if it moved past
1186
+ * the own head and the edit is honest — see `planAuthoring`. The paths this
1187
+ * node does not see are carried as the own head holds them.
1188
+ * @param scanned - The folder, as just scanned.
1131
1189
  */
1132
1190
  private _author;
1133
1191
  /**
@@ -1166,6 +1224,34 @@ export declare class FsAgent {
1166
1224
  * @param head - The network's head, or `undefined`.
1167
1225
  */
1168
1226
  private _join;
1227
+ /**
1228
+ * Joins the paths this node sees again: a pattern left its ignore list
1229
+ * since it last ran.
1230
+ *
1231
+ * While a path was ignored, this node neither wrote it nor deleted it, so
1232
+ * the folder can lack what the head holds there, or hold a version of its
1233
+ * own that never went anywhere. Authored as they stand, the first would
1234
+ * delete the network's files and the second overwrite them. So these paths
1235
+ * are joined as a joining folder is (`planJoin`): a version of this node's
1236
+ * own is set aside as a copy, one the history removed goes to
1237
+ * {@link RECOVERED_DIR}, one the history never named is new work — and the
1238
+ * head's version is written, and carried until it is there.
1239
+ * @param head - The own head.
1240
+ * @param headTree - Its tree.
1241
+ * @param folderTree - The folder, as just scanned.
1242
+ * @returns Whether anything in the folder was moved aside.
1243
+ */
1244
+ private _uncover;
1245
+ /**
1246
+ * Writes the head's version of every path `_uncover` is waiting for that is
1247
+ * not in the folder — and stops carrying each one that is, whichever
1248
+ * version: a file somebody saved there meanwhile is their work, and the
1249
+ * next edit says so.
1250
+ *
1251
+ * Asked again with every head this node hears, so a version that could not
1252
+ * be fetched — this node started offline — arrives once it can be.
1253
+ */
1254
+ private _takeUncovered;
1169
1255
  /**
1170
1256
  * Hears a head — from an announcement, a bootstrap or a state beacon.
1171
1257
  * @param head - The head.
@@ -1240,8 +1326,11 @@ export declare class FsAgent {
1240
1326
  * — content `target` holds nowhere else — is not made. Everything else is,
1241
1327
  * and the files kept become this node's work, so the folder never holds a
1242
1328
  * state the chain does not describe.
1329
+ * The paths this node does not see are neither written nor deleted, and
1330
+ * the guard counts only what the folder holds.
1243
1331
  * @param target - Where the folder should end up, `path → blob`.
1244
1332
  * @param write - Writes the given paths' `target` versions.
1333
+ * @param carried - `target`'s nodes at the paths this node does not see.
1245
1334
  * @returns `applied`; `kept` when the guard kept files `target` lacks;
1246
1335
  * `moved` when the folder had moved past the own head.
1247
1336
  */
@@ -1280,6 +1369,17 @@ export declare class FsAgent {
1280
1369
  * yet; `refused` when the merge could not be applied.
1281
1370
  */
1282
1371
  private _merge;
1372
+ /**
1373
+ * What a merge's result holds at the paths this node does not see: the node
1374
+ * of whichever side's version it kept there — and, for a copy a conflict
1375
+ * made at such a path, a node for the version the copy keeps, which the
1376
+ * merge wrote like any other copy.
1377
+ * @param merged - The merge's result, `path → blob`.
1378
+ * @param theirs - The forked head's content.
1379
+ * @param theirCarried - Its nodes at the paths this node does not see.
1380
+ * @returns The nodes to carry, by path.
1381
+ */
1382
+ private _mergeCarried;
1283
1383
  /**
1284
1384
  * Hears the network: announcements, the stamps of this node's own, and the
1285
1385
  * hub's state beacon.