diff --git a/src/main/kotlin/de/fabianonline/telegram_backup/CommandLineDownloadProgress.kt b/src/main/kotlin/de/fabianonline/telegram_backup/CommandLineDownloadProgress.kt index ac84c58..30acdba 100644 --- a/src/main/kotlin/de/fabianonline/telegram_backup/CommandLineDownloadProgress.kt +++ b/src/main/kotlin/de/fabianonline/telegram_backup/CommandLineDownloadProgress.kt @@ -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") } diff --git a/src/main/kotlin/de/fabianonline/telegram_backup/DownloadManager.kt b/src/main/kotlin/de/fabianonline/telegram_backup/DownloadManager.kt index ca60e7e..4b745a1 100644 --- a/src/main/kotlin/de/fabianonline/telegram_backup/DownloadManager.kt +++ b/src/main/kotlin/de/fabianonline/telegram_backup/DownloadManager.kt @@ -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() diff --git a/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/AbstractMediaFileManager.kt b/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/AbstractMediaFileManager.kt index 605c220..68d495a 100644 --- a/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/AbstractMediaFileManager.kt +++ b/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/AbstractMediaFileManager.kt @@ -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) { diff --git a/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/DocumentFileManager.kt b/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/DocumentFileManager.kt index bda9f1f..e032d9c 100644 --- a/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/DocumentFileManager.kt +++ b/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/DocumentFileManager.kt @@ -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 } } diff --git a/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/GeoFileManager.kt b/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/GeoFileManager.kt index b0e3f75..15726c8 100644 --- a/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/GeoFileManager.kt +++ b/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/GeoFileManager.kt @@ -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) } } diff --git a/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/PhotoFileManager.kt b/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/PhotoFileManager.kt index eedffe4..e5c5c77 100644 --- a/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/PhotoFileManager.kt +++ b/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/PhotoFileManager.kt @@ -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 } } diff --git a/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/StickerFileManager.kt b/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/StickerFileManager.kt index f0361a0..04f08b9 100644 --- a/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/StickerFileManager.kt +++ b/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/StickerFileManager.kt @@ -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 { diff --git a/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/UnsupportedFileManager.kt b/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/UnsupportedFileManager.kt index 928df48..dec94cf 100644 --- a/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/UnsupportedFileManager.kt +++ b/src/main/kotlin/de/fabianonline/telegram_backup/mediafilemanager/UnsupportedFileManager.kt @@ -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 }