Skip to content

Commit

Permalink
run withDescendents with filters (#8014)
Browse files Browse the repository at this point in the history
* stop running withDescendents for every folder

* filter by type

* clean up

* ensure all subfolders are recursed
  • Loading branch information
jackkav authored Sep 30, 2024
1 parent f4bb5c9 commit c802256
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/insomnia/src/sync/git/ne-db-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class NeDBClient {

this._workspaceId = workspaceId;
this._projectId = projectId;

}

static createClient(workspaceId: string, projectId: string): PromiseFsClient {
Expand Down Expand Up @@ -125,6 +126,9 @@ export class NeDBClient {
await db.unsafeRemove(doc, true);
}

// recurses over each .insomnia subfolder, ApiSpec, Workspace, Request etc..
// and returns a list of all the files/folders which should be in the directory
// according to the what entities are children of the workspace
async readdir(filePath: string) {
filePath = path.normalize(filePath);
const { root, type, id } = parseGitPath(filePath);
Expand Down Expand Up @@ -152,7 +156,9 @@ export class NeDBClient {
];
} else if (type !== null && id === null) {
const workspace = await db.get(models.workspace.type, this._workspaceId);
const children = await db.withDescendants(workspace);
const modelTypesWithinFolders = [models.request.type, models.grpcRequest.type, models.webSocketRequest.type];
const typeFilter = modelTypesWithinFolders.includes(type) ? [models.requestGroup.type, type] : [type];
const children = await db.withDescendants(workspace, null, typeFilter);
docs = children.filter(d => d.type === type && !d.isPrivate);
} else {
throw this._errMissing(filePath);
Expand Down

0 comments on commit c802256

Please sign in to comment.