find-unlinked-files icon indicating copy to clipboard operation
find-unlinked-files copied to clipboard

Files used in canvas are detected as orphans

Open MrJGao opened this issue 2 years ago • 4 comments

I found that when I insert an image, for example, into an obsidian canvas file, the image would be detected as an orphan when using the plugin. More importantly, I'd like to delete image files that are not used as attachments, but when I use the "delete certain orphan file types" command, the image I just inserted would be deleted.

Is there a way to exclude files used in canvas? Thanks.

MrJGao avatar Apr 18 '23 02:04 MrJGao

I can reproduce, but I don't know how to fix that. Normally, Obsidian tracks the links and embeds per file in a cache, but it does not for canvas files.

Vinzent03 avatar Apr 21 '23 09:04 Vinzent03

I can reproduce, but I don't know how to fix that. Normally, Obsidian tracks the links and embeds per file in a cache, but it does not for canvas files.

Thanks for your response.

I have an idea but not sure if it's doable. I noticed that the *.canvas files are in JSON format and they can be opened by any text editor. The *.canvas files listed all the source materials they use. So, can we read the *.canvas files manually using this extension and then find the linked images/files? Thanks.

MrJGao avatar Apr 22 '23 14:04 MrJGao

You are right, it's technical possible, but it's a bit tedious and more complicated to implement. Don't know when I get the time for this.

Vinzent03 avatar May 02 '23 19:05 Vinzent03

I would really appreciate having canvas links as part of the orphaned files search as well.

felipemeres avatar Jul 17 '23 18:07 felipemeres

For those wondering, this is fixed in the PR linked above (https://github.com/Vinzent03/find-unlinked-files/pull/53). I just used this plugin to find and delete a bunch of orphaned images without any issue, and currently my sole use of Obsidian is for a single canvas page. So AFAIK this issue can be closed.

The plugin WILL still detect the canvas page itself as an orphaned file (assuming it's not linked to from elsewhere) unless you set your filetype filters in the plugins settings to avoid that.

E.g. The top 2 settings shown below will make sure the plugin only finds orphans that are png files (thus ignoring the canvas file itself), and the bottom setting will make sure that only png files listed in the output file are considered for deletion.

Image

Also worth noting that the deletion command won't do anything at all unless you populate that last setting field.

mmseng avatar Apr 19 '25 08:04 mmseng

Thanks, @mmseng. I'm closing this issue.

MrJGao avatar Apr 19 '25 11:04 MrJGao