Skip to content

Commit 0cbdd51

Browse files
committed
devin corrections
1 parent d7b325c commit 0cbdd51

1 file changed

Lines changed: 18 additions & 12 deletions

File tree

apps/obsidian/src/utils/importNodes.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ const processFileContent = async ({
10541054
filePath: string;
10551055
importedCreatedAt?: number;
10561056
importedModifiedAt?: number;
1057-
}): Promise<{ file: TFile; error?: string }> => {
1057+
}): Promise<{ file: TFile } | { error: string }> => {
10581058
// 1. Create or update the file with the fetched content first.
10591059
// On create, set file metadata (ctime/mtime) to original vault dates via vault adapter.
10601060
let file: TFile | null = plugin.app.vault.getFileByPath(filePath);
@@ -1075,17 +1075,22 @@ const processFileContent = async ({
10751075
// often empty immediately after create/modify), then map nodeTypeId and update frontmatter.
10761076
const { frontmatter } = parseFrontmatter(rawContent);
10771077
const sourceNodeTypeId = frontmatter.nodeTypeId;
1078+
if (typeof sourceNodeTypeId !== "string")
1079+
return {
1080+
error: "importedNode missing sourceNodeTypeId",
1081+
};
10781082
const sourceNodeId = frontmatter.nodeInstanceId;
1083+
if (typeof sourceNodeId !== "string")
1084+
return {
1085+
error: "importedNode missing nodeInstanceId",
1086+
};
10791087

1080-
let mappedNodeTypeId: string | undefined;
1081-
if (sourceNodeTypeId && typeof sourceNodeTypeId === "string") {
1082-
mappedNodeTypeId = await mapNodeTypeIdToLocal({
1083-
plugin,
1084-
client,
1085-
sourceSpaceId,
1086-
sourceNodeTypeId,
1087-
});
1088-
}
1088+
const mappedNodeTypeId = await mapNodeTypeIdToLocal({
1089+
plugin,
1090+
client,
1091+
sourceSpaceId,
1092+
sourceNodeTypeId,
1093+
});
10891094

10901095
await plugin.app.fileManager.processFrontMatter(
10911096
file,
@@ -1165,10 +1170,11 @@ export const importSelectedNodes = async ({
11651170
// Process each node in this space
11661171
for (const node of nodes) {
11671172
try {
1168-
// Check if file already exists by nodeInstanceId + importedFromSpaceUri
1173+
const importedFromRid = `${spaceUri}/${node.nodeInstanceId}`;
1174+
// Check if file already exists by nodeInstanceId + importedFromRid
11691175
const existingFile = queryEngine.findExistingImportedFile(
11701176
node.nodeInstanceId,
1171-
spaceUri,
1177+
importedFromRid,
11721178
);
11731179

11741180
const nodeContent = await fetchNodeContentForImport({

0 commit comments

Comments
 (0)