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 */
|
/** This class handles the notifications, as well as the relevant key */
|
||||||
data class DownloadMetaData(
|
data class DownloadMetaData(
|
||||||
private val id: Int?,
|
private val id: Int?,
|
||||||
private val linkHash : Int,
|
private val linkHash: Int,
|
||||||
var bytesDownloaded: Long = 0,
|
var bytesDownloaded: Long = 0,
|
||||||
var bytesWritten: Long = 0,
|
var bytesWritten: Long = 0,
|
||||||
|
|
||||||
|
|
@ -543,7 +543,7 @@ object VideoDownloadManager {
|
||||||
private val createNotificationCallback: (CreateNotificationMetadata) -> Unit,
|
private val createNotificationCallback: (CreateNotificationMetadata) -> Unit,
|
||||||
|
|
||||||
private var internalType: DownloadType = DownloadType.IsPending,
|
private var internalType: DownloadType = DownloadType.IsPending,
|
||||||
val isHLS : Boolean,
|
val isHLS: Boolean,
|
||||||
// how many segments that we have downloaded
|
// how many segments that we have downloaded
|
||||||
var hlsProgress: Int = 0,
|
var hlsProgress: Int = 0,
|
||||||
// how many segments that exist
|
// 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) {
|
if (items.totalLength != null && items.totalLength < minimumSize) {
|
||||||
fileStream.closeQuietly()
|
fileStream.closeQuietly()
|
||||||
metadata.onDelete()
|
metadata.onDelete()
|
||||||
|
|
@ -1241,13 +1241,15 @@ object VideoDownloadManager {
|
||||||
metadata.type = DownloadType.IsDone
|
metadata.type = DownloadType.IsDone
|
||||||
return@withContext DOWNLOAD_SUCCESS
|
return@withContext DOWNLOAD_SUCCESS
|
||||||
} catch (e: IOException) {
|
} 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
|
// we just rethrow it
|
||||||
|
showToast(R.string.error_file_io_toast)
|
||||||
logError(e)
|
logError(e)
|
||||||
throw e
|
throw e
|
||||||
} catch (t: Throwable) {
|
} catch (t: Throwable) {
|
||||||
// some sort of network error, will error
|
// some sort of network error, will error
|
||||||
logError(t)
|
logError(t)
|
||||||
|
showToast(R.string.error_file_unknown_toast)
|
||||||
// note that when failing we don't want to delete the file,
|
// note that when failing we don't want to delete the file,
|
||||||
// only user interaction has that power
|
// only user interaction has that power
|
||||||
metadata.type = DownloadType.IsFailed
|
metadata.type = DownloadType.IsFailed
|
||||||
|
|
@ -1818,6 +1820,9 @@ object VideoDownloadManager {
|
||||||
isCompleted = true
|
isCompleted = true
|
||||||
break
|
break
|
||||||
} else if (!connectionResult.tryNext || index >= item.links.lastIndex) {
|
} else if (!connectionResult.tryNext || index >= item.links.lastIndex) {
|
||||||
|
if (connectionResult == DOWNLOAD_INVALID_INPUT) {
|
||||||
|
showToast(R.string.error_file_invalid_toast)
|
||||||
|
}
|
||||||
isFailed = true
|
isFailed = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,9 @@ object DownloadObjects {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun delete(): Boolean {
|
fun delete(): Boolean {
|
||||||
return file.delete() == true
|
return runCatching {
|
||||||
|
file.delete()
|
||||||
|
}.getOrNull() == true
|
||||||
}
|
}
|
||||||
|
|
||||||
val resume: Boolean get() = fileLength > 0L
|
val resume: Boolean get() = fileLength > 0L
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,9 @@
|
||||||
<string name="stream">Network stream</string>
|
<string name="stream">Network stream</string>
|
||||||
<string name="open_local_video">Open local video</string>
|
<string name="open_local_video">Open local video</string>
|
||||||
<string name="error_loading_links_toast">Error Loading Links</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="links_reloaded_toast">Links Reloaded</string>
|
||||||
<string name="download_storage_text">Internal Storage</string>
|
<string name="download_storage_text">Internal Storage</string>
|
||||||
<string name="app_dubbed_text">Dub</string>
|
<string name="app_dubbed_text">Dub</string>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue