mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-23 01:06:17 +00:00
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:
parent
0e2eeab5b9
commit
3a77e91bd9
@ -51,7 +51,7 @@ internal class CommandLineDownloadProgress : DownloadProgressInterface {
|
|||||||
println("'S' - Sticker 'A' - Audio 'G' - Geolocation")
|
println("'S' - Sticker 'A' - Audio 'G' - Geolocation")
|
||||||
println("'.' - Previously downloaded file 'e' - Empty file")
|
println("'.' - Previously downloaded file 'e' - Empty file")
|
||||||
println("' ' - Ignored media type (weblinks or contacts, for example)")
|
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")
|
println("" + count + " Files to check / download")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,8 +364,12 @@ class DownloadManager(internal var client: TelegramClient?, p: DownloadProgressI
|
|||||||
prog!!.onMediaAlreadyPresent(m)
|
prog!!.onMediaAlreadyPresent(m)
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
m.download()
|
val result = m.download()
|
||||||
prog!!.onMediaDownloaded(m)
|
if (result) {
|
||||||
|
prog!!.onMediaDownloaded(m)
|
||||||
|
} else {
|
||||||
|
prog!!.onMediaSkipped()
|
||||||
|
}
|
||||||
} catch (e: TimeoutException) {
|
} catch (e: TimeoutException) {
|
||||||
// do nothing - skip this file
|
// do nothing - skip this file
|
||||||
prog!!.onMediaSkipped()
|
prog!!.onMediaSkipped()
|
||||||
|
@ -78,7 +78,7 @@ abstract class AbstractMediaFileManager(protected var message: TLMessage, protec
|
|||||||
abstract val name: String
|
abstract val name: String
|
||||||
abstract val description: String
|
abstract val description: String
|
||||||
@Throws(RpcErrorException::class, IOException::class, TimeoutException::class)
|
@Throws(RpcErrorException::class, IOException::class, TimeoutException::class)
|
||||||
abstract fun download()
|
abstract fun download(): Boolean
|
||||||
|
|
||||||
protected fun extensionFromMimetype(mime: String): String {
|
protected fun extensionFromMimetype(mime: String): String {
|
||||||
when (mime) {
|
when (mime) {
|
||||||
|
@ -97,9 +97,10 @@ open class DocumentFileManager(msg: TLMessage, user: UserManager, client: Telegr
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Throws(RpcErrorException::class, IOException::class, TimeoutException::class)
|
@Throws(RpcErrorException::class, IOException::class, TimeoutException::class)
|
||||||
override fun download() {
|
override fun download(): Boolean {
|
||||||
if (doc != null) {
|
if (doc != null) {
|
||||||
DownloadManager.downloadFile(targetPathAndFilename, size, doc!!.getDcId(), doc!!.getId(), doc!!.getAccessHash())
|
DownloadManager.downloadFile(targetPathAndFilename, size, doc!!.getDcId(), doc!!.getId(), doc!!.getAccessHash())
|
||||||
}
|
}
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,11 +72,11 @@ class GeoFileManager(msg: TLMessage, user: UserManager, client: TelegramClient)
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
override fun download() {
|
override fun download(): Boolean {
|
||||||
val url = "https://maps.googleapis.com/maps/api/staticmap?" +
|
val url = "https://maps.googleapis.com/maps/api/staticmap?" +
|
||||||
"center=" + geo.getLat() + "," + geo.getLong() + "&" +
|
"center=" + geo.getLat() + "," + geo.getLong() + "&" +
|
||||||
"zoom=14&size=300x150&scale=2&format=png&" +
|
"zoom=14&size=300x150&scale=2&format=png&" +
|
||||||
"key=" + Config.SECRET_GMAPS
|
"key=" + Config.SECRET_GMAPS
|
||||||
DownloadManager.downloadExternalFile(targetPathAndFilename, url)
|
return DownloadManager.downloadExternalFile(targetPathAndFilename, url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,9 +77,10 @@ class PhotoFileManager(msg: TLMessage, user: UserManager, client: TelegramClient
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Throws(RpcErrorException::class, IOException::class, TimeoutException::class)
|
@Throws(RpcErrorException::class, IOException::class, TimeoutException::class)
|
||||||
override fun download() {
|
override fun download(): Boolean {
|
||||||
if (isEmpty) return
|
if (isEmpty) return true
|
||||||
val loc = photo_size.getLocation() as TLFileLocation
|
val loc = photo_size.getLocation() as TLFileLocation
|
||||||
DownloadManager.downloadFile(targetPathAndFilename, size, loc.getDcId(), loc.getVolumeId(), loc.getLocalId(), loc.getSecret())
|
DownloadManager.downloadFile(targetPathAndFilename, size, loc.getDcId(), loc.getVolumeId(), loc.getLocalId(), loc.getSecret())
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,16 +95,16 @@ class StickerFileManager(msg: TLMessage, user: UserManager, client: TelegramClie
|
|||||||
get() = "Sticker"
|
get() = "Sticker"
|
||||||
|
|
||||||
@Throws(RpcErrorException::class, IOException::class, TimeoutException::class)
|
@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
|
val old_file = Config.FILE_BASE + File.separatorChar + Config.FILE_STICKER_BASE + File.separatorChar + targetFilename
|
||||||
|
|
||||||
logger.trace("Old filename exists: {}", File(old_file).exists())
|
logger.trace("Old filename exists: {}", File(old_file).exists())
|
||||||
|
|
||||||
if (File(old_file).exists()) {
|
if (File(old_file).exists()) {
|
||||||
Files.copy(Paths.get(old_file), Paths.get(targetPathAndFilename), StandardCopyOption.REPLACE_EXISTING)
|
Files.copy(Paths.get(old_file), Paths.get(targetPathAndFilename), StandardCopyOption.REPLACE_EXISTING)
|
||||||
return
|
return true
|
||||||
}
|
}
|
||||||
super.download()
|
return super.download()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -54,5 +54,5 @@ class UnsupportedFileManager(msg: TLMessage, user: UserManager, client: Telegram
|
|||||||
override val letter = " "
|
override val letter = " "
|
||||||
override val description = "Unsupported / non-downloadable Media"
|
override val description = "Unsupported / non-downloadable Media"
|
||||||
|
|
||||||
override fun download() {}
|
override fun download(): Boolean = true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user