Anki suddenly can't find media

Everything worked fine yesterday.

Today, all the media are reported as missing.

Verified in the browser, and in the directory that the file names are correct (for two of the media check’s missing files) and verified that neither has added any bogus invisible characters.

However, something has made all the files empty! And they are empty in my backup, too!

Are there backups on Ankiweb that could bring back my files?

Apparently, my local backups were all trashed Sep 16 23:45, and my collection.media files were all trashed at Sep 18 18:52 (US Pacific time).

I have restored all files deleted from your AnkiWeb collection in the last few days. I can’t imagine Anki would have zeroed out your files - if you find it happens again please think of any steps/apps you may have used prior to it occurring.

I’m sure Anki could not have trashed my backups. But I forgot about the backups Anki makes. I’ll have to check whether that includes media.

The only possible cause I can think of is using rdfind to make hard links and save space. Perhaps some recent change to Apple’s file system caused this. But if rdfind did it, both directories would have the same timestamp.

How do I force a download when sync doesn’t detect the need? I got most if not all back by opening the backup Anki made. Sorry I forgot they were there earlier.

However: That restore also restored unused media files. And when I clicked to delete those again, I got an error. Did a Check DB and then tried to remove unused again. Another error.

# Error

An error occurred. Please use Tools > Check Database to see if that fixes the problem.

If problems persist, please report the problem on our [support site](https://help.ankiweb.net/). Please copy and paste the information below into your report.

Anki 2.1.33 (3f403040) Python 3.8.0 Qt 5.14.2 PyQt 5.14.2

Platform: Mac 10.15.6

Flags: frz=True ao=False sv=1

Add-ons, last update check: 2020-09-18 18:50:27

Caught exception:

Traceback (most recent call last):

File "aqt/mediacheck.py", line 100, in <lambda>

File "aqt/mediacheck.py", line 164, in _on_trash_files

File "anki/media.py", line 129, in trash_files

File "anki/rsbackend_gen.py", line 191, in trash_media_files

File "anki/rsbackend.py", line 265, in _run_command

anki.rsbackend.IOError: IOError { info: "Os { code: 1, kind: PermissionDenied, message: \"Operation not permitted\" }" }

Since it ends with permissions, I’ll check whether there’s something weird with that…

I couldn’t see any files or directories not writable by me, but just to be sure, I did
chmod -R o+w,g+w ~
then check DB and then check media, then delete unused. Same error.

Poked around some more and found a media file owned by root. One of the non-empty files restored from the backup. How could it be owned by root? Anyway, switched to admin and chown all files, then delete unused worked without error.