obsidianmd / obsidian-importer

Obsidian Importer lets you import notes from other apps and file formats into your Obsidian vault.
https://help.obsidian.md/import
MIT License
701 stars 64 forks source link

[Apple Notes] All attachments become "**error reading attachment**" after import #148

Closed dinghaoz closed 11 months ago

dinghaoz commented 11 months ago

I am on macOS 14.0 (23A344). Zero attachments are actually imported.

mirnovov commented 11 months ago

@dinghaoz This is because the importer is having trouble reading the data where your attachments are stored. Unfortunately, without more information I can't tell what exactly the cause of this is.

dinghaoz commented 11 months ago

Thanks for the reply. Here are the answers:

  1. I store my Apple Notes in iCloud.
  2. Yes, I do share a few notes with my wife, but not all.
  3. No, /Users/yourusername/Library/Group Containers/group.com.apple.notes/Accounts/bunchofrandomnumbers/ doesn't have Media folder. But /Users/yourusername/Library/Group Containers/group.com.apple.notes/Media exists though and it seems like it is where all the attachments located.
  4. Yes, they do.
  5. Yes, I prefix my notes folder with emojis to make them look more like Notion and my notes' titles are mostly in Chinese.
  6. Yes I have. @mirnovov
dinghaoz commented 11 months ago

@mirnovov I feel that the issue might be related to question 3. The code seems assuming the attachments are under group.com.apple.notes/Accounts/account-UUID/Media but they are actually at group.com.apple.notes/Media. Could that be a new thing on Sonoma? I don't have older version of Mac so can't be sure.

The code: apple-notes.ts:331

                const account = row.ZACCOUNT6 || row.ZACCOUNT5;
                sourcePath = path.join(
                    this.resolvedAccounts[account].path, 
                    'Media', row.ZIDENTIFIER, row.ZGENERATION1 || '', row.ZFILENAME
                );

But my folder hierarchy looks like this

Screenshot 2023-10-21 at 23 27 00
mirnovov commented 11 months ago

Yeah, I think this is it. Thanks for the help.

It’s not to do with the macOS version I think, I’m on Sonoma (and have tested on a bunch of other versions) and everything is under the Accounts folder for me, and this seems to be the case for the vast majority of people on all versions. Worst case scenario if I can’t figure out I can always just have it check both the first time to determine which one to use.

kepano commented 11 months ago

@mirnovov there may be some useful prior art in Apple Notes Liberator to find the location of the database

mirnovov commented 11 months ago

Unfortunately there isn’t, it assumes the files are always in the same folder like this importer currently does.

kepano commented 11 months ago

This should now be fixed if you update to Importer 1.5.3