scrapbox2ankiのapkgエラー調査.@2023-09-02
from 日刊記録sheet 2023-09-02
09:39:28 PCからだと同期できた。なんだったんだ……?
09:39:44 note typeが更新されなかったerrorを調べる
10:02:06 collection.anki21bはzstd圧縮がかかっている
閲覧するには、7-Zip-zstdを入れる必要あり
DBのupgradeが必要かも?
SQL schemaはupgradesをV11に順々に適用するとわかるらしい
説明
https://github.com/patarapolw/ankisync2/blob/master/ankisync2/anki21/db.py もわかりやすい
https://github.com/patarapolw/ankisync2/pull/8
export処理はここ
https://code2svg.vercel.app/svg/L20-33/https://raw.githubusercontent.com/ankitects/anki/main/rslib/src/import_export/service.rs#.svg https://github.com/ankitects/anki/blob/main/rslib/src/import_export/service.rs#L20-L33
https://code2svg.vercel.app/svg/L73-79/https://raw.githubusercontent.com/ankitects/anki/main/proto/anki/import_export.proto#.svg https://github.com/ankitects/anki/blob/main/proto/anki/import_export.proto#L73-L79
https://code2svg.vercel.app/svg/L23-74/https://raw.githubusercontent.com/ankitects/anki/main/rslib/src/import_export/package/apkg/export.rs#.svg https://github.com/ankitects/anki/blob/main/rslib/src/import_export/package/apkg/export.rs#L23-L74
あとはhttps://github.com/ankitects/anki/tree/main/rslib あたりを読む
大掛かりな作業になるから、避けたいところ
10:44:10 いろんな情報入れまくって頭が死んでる
すごく眠い
ここまでで調べた情報をメモする
16:23:23
上書きされなかった理由が、colを見ても分からなかった
note idは同じものを指定しているのに……
そもそも以前は上書きできた
importまわりのコードを追う
notetype.idが一致していれば、mergeを実行する
https://code2svg.vercel.app/svg/L114-123/https://raw.githubusercontent.com/ankitects/anki/main/rslib/src/import_export/package/apkg/import/notes.rs#.svg https://github.com/ankitects/anki/blob/main/rslib/src/import_export/package/apkg/import/notes.rs#L114C35-L123
schema_hashが同一で、updatedが大きいときのみ更新する
https://code2svg.vercel.app/svg/L125-138/https://raw.githubusercontent.com/ankitects/anki/main/rslib/src/import_export/package/apkg/import/notes.rs#.svg https://github.com/ankitects/anki/blob/main/rslib/src/import_export/package/apkg/import/notes.rs#L125-L138
なーるほど。field (Anki)とtemplate (Anki)の名前を追加・変更すると、別のnote type (Anki)とみなされてしまうのか
https://code2svg.vercel.app/svg/L278-287/https://raw.githubusercontent.com/ankitects/anki/main/rslib/src/import_export/package/apkg/import/notes.rs#.svg https://github.com/ankitects/anki/blob/main/rslib/src/import_export/package/apkg/import/notes.rs#L278-L287
note typeが変わってしまったのはバグではないことがわかった
わかったこと
field (Anki)とtemplate (Anki)の名前を追加・変更すると、別のnote type (Anki)とみなされてしまう
note type (Anki)を変更した既存のnote (Anki)はimportできない
Notes not updated, as notetype has been modified since you first imported the notesが発生する
翻訳ファイルのkey nameはimporting-notes-skipped-update-due-to-notetype
https://code2svg.vercel.app/svg/L176-183/https://raw.githubusercontent.com/ankitects/anki/main/rslib/src/import_export/package/apkg/import/notes.rs#.svg https://github.com/ankitects/anki/blob/main/rslib/src/import_export/package/apkg/import/notes.rs#L176-L183
やっぱり、note type idが変わっているとアウトなんだ
Anki側でnote type (Anki)を変更してから、apkgを作ってimportする必要がある
で、結局どうするか
note type (Anki)まわりの生成にはバグがないということで、このままgoする
他のscrapbox2ankiの改善点の実装に取り組もう
#2023-09-02 09:30:36