Skip to content

Commit aceb74f

Browse files
david-allisonmikehardy
authored andcommitted
docs: media.addFile
1 parent 2d448f5 commit aceb74f

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/NoteService.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import com.ichi2.anki.observability.undoableOp
4242
import org.json.JSONException
4343
import timber.log.Timber
4444
import java.io.File
45+
import java.io.IOException
4546

4647
object NoteService {
4748
/**
@@ -123,6 +124,9 @@ object NoteService {
123124
* Considering the field is new, if it has media handle it
124125
*
125126
* @param field
127+
*
128+
* @throws IOException
129+
* @throws OutOfMemoryError if the file could not be copied to a contiguous block of memory (or is >= 2GB)
126130
*/
127131
fun importMediaToDirectory(
128132
col: Collection,

libanki/src/main/java/com/ichi2/anki/libanki/Media.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ open class Media(
6161
***********************************************************
6262
*/
6363

64+
/**
65+
* @throws EmptyMediaException if [oFile] is empty or null
66+
* @throws OutOfMemoryError if the file could not be copied to a contiguous block of memory (or is >= 2GB)
67+
*/
6468
fun addFile(oFile: File?): String {
6569
if (oFile == null || oFile.length() == 0L) {
6670
throw EmptyMediaException()

libanki/src/main/java/com/ichi2/anki/libanki/exception/EmptyMediaException.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,9 @@
1515
*/
1616
package com.ichi2.anki.libanki.exception
1717

18-
// Empty media files cannot be added to AnkiWeb
18+
/**
19+
* Exception raised when attempting to add an empty, or non-existing media file
20+
*
21+
* Empty media files cannot be added to AnkiWeb
22+
*/
1923
class EmptyMediaException : Exception()

0 commit comments

Comments
 (0)