Skip to content

Commit

Permalink
- Added support for processing non-item keys by recursively listing f…
Browse files Browse the repository at this point in the history
…iles

- Implemented file discovery for keys without direct context item references
- Prevented duplicate entries in snapshot during recursive file processing
- Improved depth traversal to include files from unresolved keys
  • Loading branch information
Brian Joseph Petro committed Feb 19, 2025
1 parent 0663efe commit 3bf1600
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions smart-contexts/utils/get_snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ export async function get_snapshot(ctx_item, opts) {
async function process_depth(snapshot, curr_depth_keys, ctx_item, opts) {
console.log('curr_depth_keys', curr_depth_keys);
const curr_depth_items = (curr_depth_keys ?? []).map(key => ctx_item.get_ref(key)).filter(Boolean);
const curr_depth_non_item_keys = curr_depth_keys.filter(key => !ctx_item.get_ref(key));
// check if is folder
for (const key of curr_depth_non_item_keys) {
const smart_fs = ctx_item.env.smart_sources.fs;
const files = await smart_fs.list_files_recursive(key);
for (const file of files) {
if (is_already_in_snapshot(file.path, snapshot)) {
continue;
}
const item = ctx_item.get_ref(file.path);
if(item) {
curr_depth_items.push(item);
}
}
}
const curr_depth = {};
for (const item of curr_depth_items) {
if (is_already_in_snapshot(item.path, snapshot)) {
Expand Down

0 comments on commit 3bf1600

Please sign in to comment.