Skip to content

Commit a29c64b

Browse files
committed
fix(re-download): office file
Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
1 parent 58bcc54 commit a29c64b

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

app/src/main/java/com/owncloud/android/utils/RichDocumentDownloadAsParser.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,18 @@ object RichDocumentDownloadAsParser {
4747
val format = obj[FORMAT]?.jsonPrimitive?.contentOrNull
4848
val name = obj[NAME]?.jsonPrimitive?.contentOrNull
4949
if (format == null || url == null) return null
50-
return DownloadAs(format = format, filename = name ?: "", url = url)
50+
return DownloadAs(format = format, filename = createFilename(name, format), url = url)
5151
}
5252

5353
private fun tryParseV1(obj: JsonObject, url: String?): DownloadAs? {
5454
val type = obj[TYPE]?.jsonPrimitive?.contentOrNull
5555
val filename = obj[FILENAME]?.jsonPrimitive?.contentOrNull
5656
if (type == null || url == null) return null
57-
return DownloadAs(format = type, filename = filename ?: "", url = url)
57+
return DownloadAs(format = type, filename = createFilename(filename, type), url = url)
58+
}
59+
60+
// TODO: add correct file format
61+
private fun createFilename(filename: String?, format: String?): String {
62+
return filename ?: ("document_${System.currentTimeMillis()}")
5863
}
5964
}

0 commit comments

Comments
 (0)