pushwork 1.1.3 → 1.1.4
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/cli/commands.d.ts +71 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +794 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +19 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/config/index.d.ts +71 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +314 -0
- package/dist/config/index.js.map +1 -0
- package/dist/core/change-detection.d.ts +1 -1
- package/dist/core/change-detection.d.ts.map +1 -1
- package/dist/core/change-detection.js +16 -6
- package/dist/core/change-detection.js.map +1 -1
- package/dist/core/sync-engine.d.ts.map +1 -1
- package/dist/core/sync-engine.js +13 -1
- package/dist/core/sync-engine.js.map +1 -1
- package/dist/utils/content-similarity.d.ts +53 -0
- package/dist/utils/content-similarity.d.ts.map +1 -0
- package/dist/utils/content-similarity.js +155 -0
- package/dist/utils/content-similarity.js.map +1 -0
- package/package.json +1 -1
- package/src/core/change-detection.ts +21 -6
- package/src/core/sync-engine.ts +13 -1
|
@@ -25,6 +25,11 @@ import {
|
|
|
25
25
|
import {isContentEqual, contentHash} from "../utils/content"
|
|
26
26
|
import {out} from "../utils/output"
|
|
27
27
|
|
|
28
|
+
const isDebug = !!process.env.DEBUG
|
|
29
|
+
function debug(...args: any[]) {
|
|
30
|
+
if (isDebug) console.error("[pushwork:change-detection]", ...args)
|
|
31
|
+
}
|
|
32
|
+
|
|
28
33
|
/**
|
|
29
34
|
* Change detection engine
|
|
30
35
|
*/
|
|
@@ -50,7 +55,7 @@ export class ChangeDetector {
|
|
|
50
55
|
/**
|
|
51
56
|
* Detect all changes between local filesystem and snapshot
|
|
52
57
|
*/
|
|
53
|
-
async detectChanges(snapshot: SyncSnapshot): Promise<DetectedChange[]> {
|
|
58
|
+
async detectChanges(snapshot: SyncSnapshot, excludePaths?: Set<string>): Promise<DetectedChange[]> {
|
|
54
59
|
const changes: DetectedChange[] = []
|
|
55
60
|
|
|
56
61
|
// Get current filesystem state
|
|
@@ -65,7 +70,7 @@ export class ChangeDetector {
|
|
|
65
70
|
changes.push(...remoteChanges)
|
|
66
71
|
|
|
67
72
|
// Check for new remote documents not in snapshot (critical for clone scenarios)
|
|
68
|
-
const newRemoteDocuments = await this.detectNewRemoteDocuments(snapshot)
|
|
73
|
+
const newRemoteDocuments = await this.detectNewRemoteDocuments(snapshot, excludePaths)
|
|
69
74
|
changes.push(...newRemoteDocuments)
|
|
70
75
|
|
|
71
76
|
return changes
|
|
@@ -337,7 +342,8 @@ export class ChangeDetector {
|
|
|
337
342
|
* This is critical for clone scenarios where local snapshot is empty
|
|
338
343
|
*/
|
|
339
344
|
private async detectNewRemoteDocuments(
|
|
340
|
-
snapshot: SyncSnapshot
|
|
345
|
+
snapshot: SyncSnapshot,
|
|
346
|
+
excludePaths?: Set<string>
|
|
341
347
|
): Promise<DetectedChange[]> {
|
|
342
348
|
const changes: DetectedChange[] = []
|
|
343
349
|
|
|
@@ -352,7 +358,8 @@ export class ChangeDetector {
|
|
|
352
358
|
snapshot.rootDirectoryUrl,
|
|
353
359
|
"",
|
|
354
360
|
snapshot,
|
|
355
|
-
changes
|
|
361
|
+
changes,
|
|
362
|
+
excludePaths
|
|
356
363
|
)
|
|
357
364
|
} catch (error) {
|
|
358
365
|
out.taskLine(`Failed to discover remote documents: ${error}`, true)
|
|
@@ -368,7 +375,8 @@ export class ChangeDetector {
|
|
|
368
375
|
directoryUrl: AutomergeUrl,
|
|
369
376
|
currentPath: string,
|
|
370
377
|
snapshot: SyncSnapshot,
|
|
371
|
-
changes: DetectedChange[]
|
|
378
|
+
changes: DetectedChange[],
|
|
379
|
+
excludePaths?: Set<string>
|
|
372
380
|
): Promise<void> {
|
|
373
381
|
try {
|
|
374
382
|
// Find and wait for document to be available (retries on "unavailable")
|
|
@@ -387,6 +395,12 @@ export class ChangeDetector {
|
|
|
387
395
|
: entry.name
|
|
388
396
|
|
|
389
397
|
if (entry.type === "file") {
|
|
398
|
+
// Skip files that were deliberately deleted during this sync cycle
|
|
399
|
+
if (excludePaths?.has(entryPath)) {
|
|
400
|
+
debug(`skipping deleted path during re-detection: ${entryPath}`)
|
|
401
|
+
continue
|
|
402
|
+
}
|
|
403
|
+
|
|
390
404
|
// Check if this file is already tracked in the snapshot
|
|
391
405
|
const existingEntry = snapshot.files.get(entryPath)
|
|
392
406
|
|
|
@@ -470,7 +484,8 @@ export class ChangeDetector {
|
|
|
470
484
|
entry.url,
|
|
471
485
|
entryPath,
|
|
472
486
|
snapshot,
|
|
473
|
-
changes
|
|
487
|
+
changes,
|
|
488
|
+
excludePaths
|
|
474
489
|
)
|
|
475
490
|
}
|
|
476
491
|
}
|
package/src/core/sync-engine.ts
CHANGED
|
@@ -433,6 +433,8 @@ export class SyncEngine {
|
|
|
433
433
|
// Detect all changes
|
|
434
434
|
debug("sync: detecting changes")
|
|
435
435
|
out.update("Detecting local and remote changes")
|
|
436
|
+
// Capture pre-push snapshot file paths to detect deletions after push
|
|
437
|
+
const prePushFilePaths = new Set(snapshot.files.keys())
|
|
436
438
|
const changes = await this.changeDetector.detectChanges(snapshot)
|
|
437
439
|
|
|
438
440
|
// Detect moves
|
|
@@ -560,8 +562,18 @@ export class SyncEngine {
|
|
|
560
562
|
}
|
|
561
563
|
|
|
562
564
|
// Re-detect changes after network sync for fresh state
|
|
565
|
+
// Compute paths deleted during push so they aren't resurrected during pull
|
|
566
|
+
const deletedPaths = new Set<string>()
|
|
567
|
+
for (const p of prePushFilePaths) {
|
|
568
|
+
if (!snapshot.files.has(p)) {
|
|
569
|
+
deletedPaths.add(p)
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
if (deletedPaths.size > 0) {
|
|
573
|
+
debug(`sync: excluding ${deletedPaths.size} deleted paths from re-detection`)
|
|
574
|
+
}
|
|
563
575
|
debug("sync: re-detecting changes after network sync")
|
|
564
|
-
const freshChanges = await this.changeDetector.detectChanges(snapshot)
|
|
576
|
+
const freshChanges = await this.changeDetector.detectChanges(snapshot, deletedPaths)
|
|
565
577
|
const freshRemoteChanges = freshChanges.filter(
|
|
566
578
|
c =>
|
|
567
579
|
c.changeType === ChangeType.REMOTE_ONLY ||
|