Mark files that failed to download with an 'x' in the progress window. Also modified the legend to emphasize the fact that the file will again be tried to download during the next run.

This commit is contained in:
Fabian Schlenz 2018-02-21 06:27:35 +01:00
parent 0e2eeab5b9
commit 3a77e91bd9
8 changed files with 19 additions and 13 deletions

View File

@ -51,7 +51,7 @@ internal class CommandLineDownloadProgress : DownloadProgressInterface {
println("'S' - Sticker 'A' - Audio 'G' - Geolocation")
println("'.' - Previously downloaded file 'e' - Empty file")
println("' ' - Ignored media type (weblinks or contacts, for example)")
println("'x' - File skipped because of timeout errors")
println("'x' - File skipped because of errors - will be tried again at next run")
println("" + count + " Files to check / download")
}

View File

@ -364,8 +364,12 @@ class DownloadManager(internal var client: TelegramClient?, p: DownloadProgressI
prog!!.onMediaAlreadyPresent(m)
} else {
try {
m.download()
prog!!.onMediaDownloaded(m)
val result = m.download()
if (result) {
prog!!.onMediaDownloaded(m)
} else {
prog!!.onMediaSkipped()
}
} catch (e: TimeoutException) {
// do nothing - skip this file
prog!!.onMediaSkipped()

View File

@ -78,7 +78,7 @@ abstract class AbstractMediaFileManager(protected var message: TLMessage, protec
abstract val name: String
abstract val description: String
@Throws(RpcErrorException::class, IOException::class, TimeoutException::class)
abstract fun download()
abstract fun download(): Boolean
protected fun extensionFromMimetype(mime: String): String {
when (mime) {

View File

@ -97,9 +97,10 @@ open class DocumentFileManager(msg: TLMessage, user: UserManager, client: Telegr
}
@Throws(RpcErrorException::class, IOException::class, TimeoutException::class)
override fun download() {
override fun download(): Boolean {
if (doc != null) {
DownloadManager.downloadFile(targetPathAndFilename, size, doc!!.getDcId(), doc!!.getId(), doc!!.getAccessHash())
}
return true
}
}

View File

@ -72,11 +72,11 @@ class GeoFileManager(msg: TLMessage, user: UserManager, client: TelegramClient)
}
@Throws(IOException::class)
override fun download() {
override fun download(): Boolean {
val url = "https://maps.googleapis.com/maps/api/staticmap?" +
"center=" + geo.getLat() + "," + geo.getLong() + "&" +
"zoom=14&size=300x150&scale=2&format=png&" +
"key=" + Config.SECRET_GMAPS
DownloadManager.downloadExternalFile(targetPathAndFilename, url)
return DownloadManager.downloadExternalFile(targetPathAndFilename, url)
}
}

View File

@ -77,9 +77,10 @@ class PhotoFileManager(msg: TLMessage, user: UserManager, client: TelegramClient
}
@Throws(RpcErrorException::class, IOException::class, TimeoutException::class)
override fun download() {
if (isEmpty) return
override fun download(): Boolean {
if (isEmpty) return true
val loc = photo_size.getLocation() as TLFileLocation
DownloadManager.downloadFile(targetPathAndFilename, size, loc.getDcId(), loc.getVolumeId(), loc.getLocalId(), loc.getSecret())
return true
}
}

View File

@ -95,16 +95,16 @@ class StickerFileManager(msg: TLMessage, user: UserManager, client: TelegramClie
get() = "Sticker"
@Throws(RpcErrorException::class, IOException::class, TimeoutException::class)
override fun download() {
override fun download(): Boolean {
val old_file = Config.FILE_BASE + File.separatorChar + Config.FILE_STICKER_BASE + File.separatorChar + targetFilename
logger.trace("Old filename exists: {}", File(old_file).exists())
if (File(old_file).exists()) {
Files.copy(Paths.get(old_file), Paths.get(targetPathAndFilename), StandardCopyOption.REPLACE_EXISTING)
return
return true
}
super.download()
return super.download()
}
companion object {

View File

@ -54,5 +54,5 @@ class UnsupportedFileManager(msg: TLMessage, user: UserManager, client: Telegram
override val letter = " "
override val description = "Unsupported / non-downloadable Media"
override fun download() {}
override fun download(): Boolean = true
}