1
0
mirror of https://github.com/fabianonline/telegram_backup.git synced 2024-11-23 01:06:17 +00:00

Moved the stickers into the files directory of the individual accounts. Instead of downloading the stickers again, they will be copied from the old location. Closes #25.

This commit is contained in:
Fabian Schlenz 2016-10-05 13:41:11 +02:00
parent cb36fb29a6
commit 3a615f94af

View File

@ -33,9 +33,16 @@ import com.github.badoualy.telegram.tl.api.upload.TLFile;
import com.github.badoualy.telegram.tl.exception.RpcErrorException; import com.github.badoualy.telegram.tl.exception.RpcErrorException;
import com.github.badoualy.telegram.tl.api.request.TLRequestUploadGetFile; import com.github.badoualy.telegram.tl.api.request.TLRequestUploadGetFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.net.URL; import java.net.URL;
@ -44,6 +51,8 @@ import java.util.concurrent.TimeoutException;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
public class StickerFileManager extends DocumentFileManager { public class StickerFileManager extends DocumentFileManager {
private static Logger logger = LoggerFactory.getLogger(StickerFileManager.class);
public StickerFileManager(TLMessage msg, UserManager user, TelegramClient client) { public StickerFileManager(TLMessage msg, UserManager user, TelegramClient client) {
super(msg, user, client); super(msg, user, client);
} }
@ -74,11 +83,23 @@ public class StickerFileManager extends DocumentFileManager {
} }
public String getTargetPath() { public String getTargetPath() {
String path = Config.FILE_BASE + File.separatorChar + Config.FILE_STICKER_BASE + File.separatorChar; String path = user.getFileBase() + Config.FILE_FILES_BASE + File.separatorChar + Config.FILE_STICKER_BASE + File.separatorChar;
new File(path).mkdirs(); new File(path).mkdirs();
return path; return path;
} }
public void download() throws RpcErrorException, IOException {
String old_file = Config.FILE_BASE + File.separatorChar + Config.FILE_STICKER_BASE + File.separatorChar + getTargetFilename();
logger.trace("Old filename exists: {}", new File(old_file).exists());
if (new File(old_file).exists()) {
Files.copy(Paths.get(old_file), Paths.get(getTargetPathAndFilename()), StandardCopyOption.REPLACE_EXISTING);
return;
}
super.download();
}
public String getExtension() { return "webp"; } public String getExtension() { return "webp"; }
public String getLetter() { return "s"; } public String getLetter() { return "s"; }