anki icon indicating copy to clipboard operation
anki copied to clipboard

[BUG/Android]: trash_media_files - Cross-device link (os error 18)

Open david-allison opened this issue 4 months ago • 2 comments

Still diagnosing on our side, I'll relay relevant information here.

At a quick glance, it feels the fs::rename would be the issue, but I don't see how the cross-device link would be produced via the Rust.

  • https://github.com/ankidroid/Anki-Android/issues/19134
net.ankiweb.rsdroid.BackendException$BackendCardTypeException: Cross-device link (os error 18)
	at net.ankiweb.rsdroid.exceptions.BackendIoException.<init>(BackendIoException.java:23)
	at net.ankiweb.rsdroid.BackendException$Companion.fromError(BackendException.kt:197)
	at net.ankiweb.rsdroid.BackendKt.unpackResult(Backend.kt:317)
	at net.ankiweb.rsdroid.BackendKt.access$unpackResult(Backend.kt:1)
	at net.ankiweb.rsdroid.Backend.runMethodRaw$lambda$1(Backend.kt:133)
	at net.ankiweb.rsdroid.Backend.withBackend(Backend.kt:145)
	at net.ankiweb.rsdroid.Backend.runMethodRaw(Backend.kt:132)
	at anki.backend.GeneratedBackend.trashMediaFilesRaw(GeneratedBackend.kt:2889)
	at anki.backend.GeneratedBackend.trashMediaFiles(GeneratedBackend.kt:2896)
	at com.ichi2.anki.libanki.Media.trashFiles(Media.kt:156)

deckPath: /storage/emulated/0/Android/data/com.ichi2.anki/files/AnkiDroid

Relevant code

https://github.com/ankitects/anki/blob/3d0a408a2b1f86a647e2f3e6eee20893fa0dc706/rslib/src/media/service.rs#L43-L45 https://github.com/ankitects/anki/blob/3d0a408a2b1f86a647e2f3e6eee20893fa0dc706/rslib/src/media/mod.rs#L92-L108 https://github.com/ankitects/anki/blob/3d0a408a2b1f86a647e2f3e6eee20893fa0dc706/rslib/src/media/files.rs#L323-L362

david-allison avatar Aug 25 '25 11:08 david-allison

trash_folder() was designed to create the trash folder in the same folder parent folder as the media folder, to avoid such issues, so the error is surprising. Is it only one user affected?

dae avatar Sep 17 '25 03:09 dae

Only one user affected, and I haven't heard back from them

david-allison avatar Sep 17 '25 04:09 david-allison