MCPcopy Create free account
hub / github.com/cloudflare/agents / deleteDescendants

Method deleteDescendants

packages/shell/src/filesystem.ts:1514–1540  ·  view source on GitHub ↗
(dirPath: string)

Source from the content-addressed store, hash-verified

1512 }
1513
1514 private async deleteDescendants(dirPath: string): Promise<void> {
1515 const pattern = escapeLike(dirPath) + "/%";
1516 const T = this.tableName;
1517
1518 const r2Rows = await this.sql.query<{ r2_key: string }>(
1519 `SELECT r2_key FROM ${T}
1520 WHERE path LIKE ? ESCAPE ?
1521 AND storage_backend = 'r2'
1522 AND r2_key IS NOT NULL`,
1523 pattern,
1524 LIKE_ESCAPE
1525 );
1526
1527 if (r2Rows.length > 0) {
1528 const r2 = this.getR2();
1529 if (r2) {
1530 const keys = r2Rows.map((r) => r.r2_key);
1531 await r2.delete(keys);
1532 }
1533 }
1534
1535 await this.sql.run(
1536 `DELETE FROM ${T} WHERE path LIKE ? ESCAPE ?`,
1537 pattern,
1538 LIKE_ESCAPE
1539 );
1540 }
1541}
1542
1543// ── Base64 helpers ───────────────────────────────────────────────────

Callers 1

rmMethod · 0.95

Calls 4

getR2Method · 0.95
escapeLikeFunction · 0.85
deleteMethod · 0.65
runMethod · 0.65

Tested by

no test coverage detected