Skip to content

[PHP] Add exact local cleanup to file sync patches - #587

Open
adamziel wants to merge 1 commit into
codex/share-file-index-path-inspectionfrom
codex/share-file-sync-cleanup
Open

[PHP] Add exact local cleanup to file sync patches#587
adamziel wants to merge 1 commit into
codex/share-file-index-path-inspectionfrom
codex/share-file-sync-cleanup

Conversation

@adamziel

@adamziel adamziel commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

File sync cleanup can now remove selected indexed paths without removing skipped or excluded children.

FileSyncPatchProcessor::start_from_fresh_local_tree() plans exact deletions. The push direction keeps collapsing deleted subtrees to one root.

FileSyncCleanupProcessor removes one exact file, link, or empty directory per step. It uses unlink() and rmdir() and never walks a directory recursively. If a cache, storage, excluded, or newly created child remains, its parent remains too. After the exact removals, cleanup prunes one unchanged empty parent per step.

The cursor stores a pending removal and the local type, size, and ctime seen by the fresh scan. Cleanup checks those fields before removing the path. If they changed, it returns restart and leaves the new path alone.

$cleanup = FileSyncCleanupProcessor::start(
    $work_directory,
    $filesystem_root,
    $patch_result_index,
    $storage_path,
    ["wp-content"],
    ["wp-content/uploads/keep"]
);

do {
    $has_next_step = $cleanup->next_step();
    $cleanup->flush_pending_output();
    save_cursor($cleanup->get_cursor());
} while ($has_next_step);

$status = $cleanup->get_status();
$cleanup->close();

if ($status === "restart") {
    restart_file_sync();
}

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Pull pipeline performance — large-directory

Site: large-directory · 2,000+ plus targeted file-transfer scenarios files · 10,000 posts · 25,000 postmeta · PHP 8.5.9

Stage PR trunk Δ Status Details
playground-sqlite-db-pull 10.27 s 9.59 s ⚪ +678 ms (+7.1%) condition=db-pull in PHP.wasm
runtime=php.wasm 8.3
wp_mysql_parser=enabled
mode=lexer
native_lexer=verified
native_token_stream=WP_MySQL_Native_Token_Stream
native_token_count=18
native_parser=selected
trunk: condition=db-pull in PHP.wasm
runtime=php.wasm 8.3
wp_mysql_parser=enabled
mode=lexer
native_lexer=verified
native_token_stream=WP_MySQL_Native_Token_Stream
native_token_count=18
native_parser=selected
playground-sqlite-db-apply 3.75 s 3.74 s ⚪ +17 ms (+0.5%) condition=db-apply to SQLite in PHP.wasm
runtime=php.wasm 8.3
wp_mysql_parser=enabled
mode=parser
native_lexer=verified
native_token_stream=WP_MySQL_Native_Token_Stream
native_token_count=18
native_parser=verified
native_ast=WP_MySQL_Native_Parser_Node
sqlite_driver_parser=verified
trunk: condition=db-apply to SQLite in PHP.wasm
runtime=php.wasm 8.3
wp_mysql_parser=enabled
mode=parser
native_lexer=verified
native_token_stream=WP_MySQL_Native_Token_Stream
native_token_count=18
native_parser=verified
native_ast=WP_MySQL_Native_Parser_Node
sqlite_driver_parser=verified
Total 14.02 s 13.33 s ⚪ +695 ms (+5.2%)

Numbers carry runner noise; treat single-run deltas as directional, not authoritative.

📈 Trunk performance history — commit-by-commit timeline.

@adamziel
adamziel force-pushed the codex/share-file-sync-cleanup branch from a6e41d5 to 688f690 Compare August 14, 2026 01:25
@adamziel
adamziel force-pushed the codex/share-file-sync-cleanup branch from 688f690 to c628e01 Compare August 14, 2026 01:39
@adamziel
adamziel changed the base branch from codex/selection-aware-remote-deletion to codex/share-file-index-path-inspection August 14, 2026 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant