mirror of
https://github.com/recloudstream/cloudstream.git
synced 2026-10-22 18:14:16 +00:00
Compare commits
1 commit
master
...
fix-downlo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9fa1540e85 |
3 changed files with 15 additions and 5 deletions
|
|
@ -531,7 +531,7 @@ object VideoDownloadManager {
|
|||
/** This class handles the notifications, as well as the relevant key */
|
||||
data class DownloadMetaData(
|
||||
private val id: Int?,
|
||||
private val linkHash : Int,
|
||||
private val linkHash: Int,
|
||||
var bytesDownloaded: Long = 0,
|
||||
var bytesWritten: Long = 0,
|
||||
|
||||
|
|
@ -543,7 +543,7 @@ object VideoDownloadManager {
|
|||
private val createNotificationCallback: (CreateNotificationMetadata) -> Unit,
|
||||
|
||||
private var internalType: DownloadType = DownloadType.IsPending,
|
||||
val isHLS : Boolean,
|
||||
val isHLS: Boolean,
|
||||
// how many segments that we have downloaded
|
||||
var hlsProgress: Int = 0,
|
||||
// how many segments that exist
|
||||
|
|
@ -1045,7 +1045,7 @@ object VideoDownloadManager {
|
|||
)
|
||||
)
|
||||
|
||||
// too short file, treat it as a invalid link
|
||||
// too short file, treat it as an invalid link
|
||||
if (items.totalLength != null && items.totalLength < minimumSize) {
|
||||
fileStream.closeQuietly()
|
||||
metadata.onDelete()
|
||||
|
|
@ -1241,13 +1241,15 @@ object VideoDownloadManager {
|
|||
metadata.type = DownloadType.IsDone
|
||||
return@withContext DOWNLOAD_SUCCESS
|
||||
} catch (e: IOException) {
|
||||
// some sort of IO error, this should not happened
|
||||
// some sort of IO error, this usually happens when storage access is revoked
|
||||
// we just rethrow it
|
||||
showToast(R.string.error_file_io_toast)
|
||||
logError(e)
|
||||
throw e
|
||||
} catch (t: Throwable) {
|
||||
// some sort of network error, will error
|
||||
logError(t)
|
||||
showToast(R.string.error_file_unknown_toast)
|
||||
// note that when failing we don't want to delete the file,
|
||||
// only user interaction has that power
|
||||
metadata.type = DownloadType.IsFailed
|
||||
|
|
@ -1818,6 +1820,9 @@ object VideoDownloadManager {
|
|||
isCompleted = true
|
||||
break
|
||||
} else if (!connectionResult.tryNext || index >= item.links.lastIndex) {
|
||||
if (connectionResult == DOWNLOAD_INVALID_INPUT) {
|
||||
showToast(R.string.error_file_invalid_toast)
|
||||
}
|
||||
isFailed = true
|
||||
break
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,7 +215,9 @@ object DownloadObjects {
|
|||
}
|
||||
|
||||
fun delete(): Boolean {
|
||||
return file.delete() == true
|
||||
return runCatching {
|
||||
file.delete()
|
||||
}.getOrNull() == true
|
||||
}
|
||||
|
||||
val resume: Boolean get() = fileLength > 0L
|
||||
|
|
|
|||
|
|
@ -83,6 +83,9 @@
|
|||
<string name="stream">Network stream</string>
|
||||
<string name="open_local_video">Open local video</string>
|
||||
<string name="error_loading_links_toast">Error Loading Links</string>
|
||||
<string name="error_file_io_toast">Error occurred when writing to the file. Try setting a new download directory.</string>
|
||||
<string name="error_file_unknown_toast">Error occurred when downloading the file. Try again.</string>
|
||||
<string name="error_file_invalid_toast">Download source is invalid. Try another source.</string>
|
||||
<string name="links_reloaded_toast">Links Reloaded</string>
|
||||
<string name="download_storage_text">Internal Storage</string>
|
||||
<string name="app_dubbed_text">Dub</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue