Skip to content

Commit af44099

Browse files
committed
fix: handle empty canvas file
close #66
1 parent 3f8afba commit af44099

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,10 @@ export default class FindOrphanedFilesPlugin extends Plugin {
237237
async (canvasFile: TFile) => {
238238
// Read the canvas file as JSON
239239
const canvasFileContent: CanvasData = JSON.parse(
240-
await this.app.vault.cachedRead(canvasFile)
240+
(await this.app.vault.cachedRead(canvasFile)) || "{}"
241241
);
242242
// Get a list of all links within the canvas file
243-
canvasFileContent.nodes.forEach((node) => {
243+
canvasFileContent.nodes?.forEach((node) => {
244244
let linkTexts: string[] = [];
245245

246246
if (node.type === "file") {

0 commit comments

Comments
 (0)