mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-23 01:06:17 +00:00
Merge branch 'master' into stable
This commit is contained in:
commit
1c0df1b92c
@ -1,9 +1,8 @@
|
|||||||
language: java
|
language: java
|
||||||
jdk:
|
|
||||||
- oraclejdk8
|
|
||||||
- oraclejdk9
|
|
||||||
- openjdk7
|
|
||||||
|
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
before_cache:
|
before_cache:
|
||||||
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
|
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
|
||||||
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
|
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
FROM openjdk:8
|
FROM openjdk:8
|
||||||
|
|
||||||
ENV JAR_VERSION 1.1.1
|
ENV JAR_VERSION 1.1.2
|
||||||
ENV JAR_DOWNLOAD_URL https://github.com/fabianonline/telegram_backup/releases/download/${JAR_VERSION}/telegram_backup.jar
|
ENV JAR_DOWNLOAD_URL https://github.com/fabianonline/telegram_backup/releases/download/${JAR_VERSION}/telegram_backup.jar
|
||||||
|
|
||||||
RUN apt-get update -y && apt-get install -y curl && \
|
RUN apt-get update -y && apt-get install -y curl && \
|
||||||
|
@ -143,6 +143,8 @@ class CommandLineController {
|
|||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
logger.error("Exception caught!", e)
|
logger.error("Exception caught!", e)
|
||||||
|
// If we encountered an exception, we definitely don't want to start the daemon mode now.
|
||||||
|
CommandLineOptions.cmd_daemon = false
|
||||||
} finally {
|
} finally {
|
||||||
if (CommandLineOptions.cmd_daemon) {
|
if (CommandLineOptions.cmd_daemon) {
|
||||||
handler.activate()
|
handler.activate()
|
||||||
|
@ -46,7 +46,7 @@ object Config {
|
|||||||
|
|
||||||
var DEFAULT_PAGINATION = 5_000
|
var DEFAULT_PAGINATION = 5_000
|
||||||
|
|
||||||
val SECRET_GMAPS = "AI" + "za" + "SyD_2" + "c0DKsfCXqgG" + "z0Sip7KHsBCU-paBfeJk"
|
val SECRET_GMAPS = "AI" + "za" + "SyD_" + "c0DKsfCXqgG" + "z0Sip7KHsBCU-paBfeJk"
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val p = Properties()
|
val p = Properties()
|
||||||
|
@ -381,21 +381,30 @@ internal class DB_Update_9(conn: Connection, db: Database) : DatabaseUpdate(conn
|
|||||||
override fun _doUpdate() {
|
override fun _doUpdate() {
|
||||||
val logger = LoggerFactory.getLogger(DB_Update_9::class.java)
|
val logger = LoggerFactory.getLogger(DB_Update_9::class.java)
|
||||||
println(" Updating supergroup channel message data (this might take some time)...")
|
println(" Updating supergroup channel message data (this might take some time)...")
|
||||||
val rs = stmt.executeQuery("SELECT id, data, source_id FROM messages WHERE source_type='channel' and sender_id IS NULL and api_layer=53")
|
val count = db.queryInt("SELECT COUNT(*) FROM messages WHERE source_type='channel' and sender_id IS NULL and api_layer=53")
|
||||||
val messages = TLVector<TLAbsMessage>()
|
logger.debug("Found $count candidates for conversion")
|
||||||
val messages_to_delete = mutableListOf<Int>()
|
val limit = 5000
|
||||||
|
var offset = 0
|
||||||
var i = 0
|
var i = 0
|
||||||
while (rs.next()) {
|
while (offset + 1 < count) {
|
||||||
i++
|
logger.debug("Querying with limit $limit and offset $offset")
|
||||||
val msg = Database.bytesToTLMessage(rs.getBytes(2))
|
val rs = stmt.executeQuery("SELECT id, data, source_id FROM messages WHERE source_type='channel' and sender_id IS NULL and api_layer=53 LIMIT ${limit} OFFSET ${offset}")
|
||||||
if (msg!!.getFromId() != null) {
|
val messages = TLVector<TLAbsMessage>()
|
||||||
messages.add(msg)
|
val messages_to_delete = mutableListOf<Int>()
|
||||||
messages_to_delete.add(rs.getInt(1))
|
while (rs.next()) {
|
||||||
|
val msg = Database.bytesToTLMessage(rs.getBytes(2))
|
||||||
|
if (msg!!.getFromId() != null) {
|
||||||
|
i++
|
||||||
|
messages.add(msg)
|
||||||
|
messages_to_delete.add(rs.getInt(1))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
db.saveMessages(messages, api_layer=53, source_type=MessageSource.SUPERGROUP)
|
||||||
|
execute("DELETE FROM messages WHERE id IN (" + messages_to_delete.joinToString() + ")")
|
||||||
|
|
||||||
|
offset += limit
|
||||||
}
|
}
|
||||||
logger.info("Converted ${messages.size} of ${i} messages.")
|
logger.info("Converted ${i} of ${count} messages.")
|
||||||
db.saveMessages(messages, api_layer=53, source_type=MessageSource.SUPERGROUP)
|
|
||||||
execute("DELETE FROM messages WHERE id IN (" + messages_to_delete.joinToString() + ")")
|
|
||||||
println(" Cleaning up the database (this might also take some time, sorry)...")
|
println(" Cleaning up the database (this might also take some time, sorry)...")
|
||||||
execute("VACUUM")
|
execute("VACUUM")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user