You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add explicit empty directory markers via memory_add_content('dirname/', '') for path-preserving virtual filesystem workflows. Directory marker creation now requires preserve_duplicate_paths=1, stores marker paths with a trailing slash, rejects file/directory conflicts, and keeps markers out of search indexes.
Update listing, delete, rename, materialize, directory sync cleanup, and reindex paths to handle markers consistently. Document the new behavior and add focused unit coverage for marker creation, conflicts, listing, deletion, materialization, and reindex survival.
Copy file name to clipboardExpand all lines: API.md
+12-3Lines changed: 12 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -308,11 +308,16 @@ Indexes caller-provided file content without reading from the filesystem.
308
308
- If the path was previously indexed with different content, the old entry (chunks, embeddings, FTS) is deleted and new content is reindexed
309
309
- If the new content is already indexed under another path, the stale path is removed and the existing content entry is reused
310
310
- Set `preserve_duplicate_paths=1` to preserve separate rows for distinct paths with identical or empty content
311
+
- With `preserve_duplicate_paths=1`, an empty `content` value and a trailing slash in `path` creates an explicit empty directory marker, for example `memory_add_content('dirname/', '')`
312
+
- Directory markers are stored in `dbmem_content` with a trailing slash path, are shown as directories by `memory_list_files()`, and are not indexed for search
313
+
- Directory marker paths cannot contain non-empty content and cannot conflict with a file path of the same name
311
314
- Available even when compiled with `DBMEM_OMIT_IO`
312
315
313
316
**Example:**
314
317
```sql
315
318
SELECT memory_add_content('docs/api.md', '# API\nContent already loaded by the caller.', 'documentation');
@@ -334,6 +339,7 @@ Renames an indexed file path in memory without reprocessing content.
334
339
- It does not rename the file on disk or change the stored `source_path` value
335
340
- Does not change `hash`, `value`, embeddings, or FTS entries
336
341
- Fails if `new_path` already exists because `dbmem_content.path` is unique
342
+
- Explicit directory markers can be renamed only to another trailing-slash marker path; this renames only the marker row, not child paths
337
343
- Fails if `old_path` matches more than one row across `path` and local `dbmem_content_source.source_path`; pass a unique logical path or exact local source path
338
344
339
345
**Example:**
@@ -392,10 +398,11 @@ Writes all stored file contents from `dbmem_content` back to the filesystem.
392
398
|-----------|------|----------|-------------|
393
399
|`root_path`| TEXT | No | Filesystem root used to materialize relative paths |
394
400
395
-
**Returns:** INTEGER - Number of files processed
401
+
**Returns:** INTEGER - Number of files or explicit directory markers processed
396
402
397
403
**Notes:**
398
404
- Creates parent directories as needed
405
+
- Explicit directory markers created with `memory_add_content('dirname/', '')` are materialized as directories
399
406
- Relative paths are written under `root_path` when provided
400
407
- Paths containing `..` segments are rejected to prevent writing outside the materialization root
401
408
- If a file already exists with the same content, it is left unchanged and no error is returned
@@ -421,7 +428,7 @@ Returns a JSON tree with the indexed directories and files stored in `dbmem_cont
421
428
**Notes:**
422
429
- Rows added with `memory_add_text()` use generated paths and can appear as root-level file nodes
423
430
- Legacy absolute paths are displayed with their common directory prefix removed when possible
424
-
- Directory nodes are derived from indexed file paths
431
+
- Directory nodes are derived from indexed file paths and explicit directory markers
425
432
- Path separators are normalized to `/` in the returned JSON
426
433
- Sibling nodes are sorted with directories first, then files; each group is alphabetical
Directory markers are listed as directories, materialized as directories by `memory_materialize_files()`, and ignored by `memory_search`.
243
+
235
244
`memory_add_text()`, `memory_add_file()`, and `memory_add_content()` each run inside a SQLite SAVEPOINT transaction. `memory_add_directory()` performs its cleanup pass transactionally and then processes each file in its own transaction. If one file fails, that file rolls back cleanly and previously-committed files remain valid; there are no partially-indexed rows or orphaned chunk/FTS entries for the failed file.
236
245
237
246
This makes all sync functions safe to call repeatedly - for example, on a cron schedule or at agent startup - with minimal overhead.
0 commit comments