mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-22 16:56:16 +00:00
Trying to rename downloaded files more than once. This could help against aggressive anti virus tools.
This commit is contained in:
parent
7e26ff0849
commit
3db48864bc
@ -40,6 +40,9 @@ public class Config {
|
|||||||
public static int DELAY_AFTER_GET_MESSAGES = 100;
|
public static int DELAY_AFTER_GET_MESSAGES = 100;
|
||||||
public static int DELAY_AFTER_GET_FILE = 100;
|
public static int DELAY_AFTER_GET_FILE = 100;
|
||||||
|
|
||||||
|
public static int RENAMING_MAX_TRIES = 5;
|
||||||
|
public static int RENAMING_DELAY = 1000;
|
||||||
|
|
||||||
public static final String SECRET_GMAPS = "AIzaSyBEtUDhCQKEH6i2Mn1GAiQ9M_tLN0vxHIs";
|
public static final String SECRET_GMAPS = "AIzaSyBEtUDhCQKEH6i2Mn1GAiQ9M_tLN0vxHIs";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -311,7 +311,23 @@ public class DownloadManager {
|
|||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
logger.trace("Renaming {} to {}", temp_filename, target);
|
logger.trace("Renaming {} to {}", temp_filename, target);
|
||||||
Files.move(new File(temp_filename).toPath(), new File(target).toPath(), StandardCopyOption.REPLACE_EXISTING);
|
int rename_tries = 0;
|
||||||
|
IOException last_exception = null;
|
||||||
|
while (rename_tries <= Config.RENAMING_MAX_TRIES) {
|
||||||
|
rename_tries++;
|
||||||
|
try {
|
||||||
|
Files.move(new File(temp_filename).toPath(), new File(target).toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
last_exception = null;
|
||||||
|
break;
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.debug("Exception during move. rename_tries: {}. Exception: {}", rename_tries, e);
|
||||||
|
last_exception = e;
|
||||||
|
try { Thread.sleep(Config.RENAMING_DELAY); } catch (InterruptedException e2) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (last_exception != null) {
|
||||||
|
throw last_exception;
|
||||||
|
}
|
||||||
last_download_succeeded = true;
|
last_download_succeeded = true;
|
||||||
return true;
|
return true;
|
||||||
} catch (java.io.IOException ex) {
|
} catch (java.io.IOException ex) {
|
||||||
|
Loading…
Reference in New Issue
Block a user