The import file (import deck) dialog has become rather helpful in recent versions of Anki, but one oddity is that the “{int} notes were used to update existing ones” seems to count total notes that have ever been updated since the initial import, rather than any notes that have actually been updated by the current import operation. This makes the feature less useful for identifying which notes have been changed by the current import, but rather all changes since the beginning accumulate over multiple updates.
In the screenshot above, I had updated only one note. The “Show” button in that context was therefore not as helpful as it could have been.
A simple test would be to export a deck and import in another profile. Then go back to the original profile and update a note. Then, in the second profile, import it. The note should be reported as updated. Import the same, and it will show as imported again. It should be expected that subsequent imports of the same file should not note any updated notes, since no notes have actually been updated.
Without looking in detail, my guess is that the following change is likely the cause:
If I understand correctly that mtime is a record of the time the note was modified (I am unfamiliar with this specific programming context), then restoring mtime to its previous value is the problem. I understand the problem the commit was trying to solve. I believe the best solution would be to set mtime to match the time of the imported note (the mtime of the imported note? Sorry I can’t be precise.).
I’m an outsider when it comes to how it works. My above guess could be completely wrong.
Can’t reproduce this. Importing a test apkg shows “3 notes imported”. Modifying one note, exporting and importing shows “1 note updated” and re-importing that doesn’t report any notes updated. Could be something inherent in your deck perhaps
The condition for updating a note during import is if the existing mtime is strictly older (less) than the incoming mtime. Re-importing the same apkg won’t cause an update.
That’s what the pr did, it uses the mtime of the incoming note. Previously it was the time of the import operation itself
I forgot to mention that I have “Update notes” and “Update note types” set to “Always.” With those settings, reimporting the same file will keep reporting updated notes in that case, even though no changes were made after the first import. Are you able to reproduce with those import options?
Thanks for confirming. I took a gamble on trying to be helpful without knowing all the facts (I don’t know this programming language, for example).
Maybe it is something wrong with the logic of the “Always” import option. The “If newer” option does not manifest this behavior.
If I make a single change to the same collection as in the screenshot above, then import into the other profile, then this is what happens with each setting:
Update notes set to “If newer.” On the first import of the export file, it reports 1 note has been updated. On subsequent imports of the same export file, it does not report any notes updated.
Update notes set to “Always.” On the first import of the export file, it reports 388 notes have been updated. On subsequent imports of the same export file, it continues to report 388 notes have been updated. Notice that 388 is one higher than the 387 in the initial screenshot. That is the accumulation I was talking about: I had changed one note in this test.
Tried testing with this, updating a note on the second profile and importing caused it to be updated (reverted), and re-importing again didn’t show any updated notes, so still can’t reproduce unfortunately
The condition for updating when set to “always” is if the existing and incoming mtimes don’t match. Which was almost always the case before the pr, but now shouldn’t happen anymore after it, if importing the same apkg
Is this a recurring issue (i.e reimporting the apkg still shows 388 notes updated over and over again on the same profile) or a one-off? I can’t see why the mtimes wouldn’t match up after one import
Exporting and re-importing on the same profile without modification, with update set to “always” also reports no notes updated, so exporting doesn’t seem to mess up the mtimes either
Ah, that is a very interesting detail. When I test exporting (without any changes) and importing from the same profile, then it does not report any updates. But when I export (without any changes) and import into a different profile that has the same deck, it will report 388 changes every time. I have tried exporting and importing in both directions, that is, swapping which profile exports and imports.
Not necessarily always, but it does seem the logical choice. I manage notes for my children, and when I import changes to their profiles, I expect my changes to be copied to their notes whether or not they may have happened to edit the notes themselves (maybe just out of experimentation or whatever) at a later date than any corrections I made.
If you still cannot reproduce when importing into different profiles, then I can share with you a couple of exports from a new test deck I have made. When importing these into a newly created profile, these fresh exports manifest the problem consistently.
That is the issue. I feel bad that I didn’t give the Anki version at the start, because I know better.
I have installed Anki 25.01rc1 to test, and the problem is indeed resolved. It took one import of the same exports again, presumably just to set the mtime fields to the proper values, and then subsequent imports had the expected results.
Thank you for working through this, and also for the fix that you have already submitted.
Also, I really like the somewhat new changes to the import procedure that show which notes were updated and which were new, especially the “Show” button. That has really simplified managing imports for my children. Thanks to whomever worked to make that possible.