Sync'd images not displaying and IOError after symlinking

Several days ago, I symlinked collection.media and collection.anki2 to Dropbox (I wasn’t aware that this is a bad idea at the time). Since then, there have been two issues:

  1. On startup, close and sync, I get the error: IOError { info: "unable to read collection.media: No such file or directory (os error 2)" }. The error doesn’t occur with shift startup (which leads me to believe the sync event triggers the error). image
  2. media doesn’t display through ankiweb sync (but media displays fine via local anki desktop):
    image

I’ve tried the following yet 1. and 2. persist:
3. disabling all plugins
4. replacing the symlinks with the original files
5. importing a backup of date prior to creating symlinks
6. checking that the collections.media filename matches ankiweb

collection.media/paste-feaa17546c4336679924918e6639df1284173368.jpg
<img src="paste-feaa17546c4336679924918e6639df1284173368.jpg">

I’m not sure what could be causing the IOError at this point since collection.media is in the original location (and is not a symlink) and media displays fine locally. I don’t know what other data sources might be be relevant. As far as I can tell, collection.anki2 is not corrupt (Check Database report seems fine and Anki Desktop works normally aside from the IOError messages).

Any advice on how to proceed? Since I have backups, my next thought would be to reinstall Anki Desktop fresh and import.

Hmm…
Tracing this “unable to read” message in Anki’s source, I found these two occurences:

But AFAIK, in both places, Anki should be trying to open a media file rather than the collection.media directory.
It seems some file in your media directory is somehow ending up appearing with an empty name in these places.

2 Likes

I tried clearing media by renaming to collection.media.bak, creating a new card with image, and syncing to ankiweb. The IOErrors go away but the image still doesn’t display on ankiweb.

If you can run from source, maybe try inserting some print statements before that error message in both places to find which one exactly is getting triggered. Maybe this will help pinpoint the source of the issue.

Like:

println!("sha1_of_file: {}", fname);

println!("data_for_file: {}", fname);
1 Like

I realized the IOError was caused by a symlink named collection.media inside collection.media. Symlink misadventures :expressionless:. And the image display issue no longer occurs after forcing a one way sync.

Thanks for your help and sorry for the confusion.

2 Likes