mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-22 16:56:16 +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:
parent
cb36fb29a6
commit
3a615f94af
@ -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.api.request.TLRequestUploadGetFile;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
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.LinkedList;
|
||||
import java.net.URL;
|
||||
@ -44,6 +51,8 @@ import java.util.concurrent.TimeoutException;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
public class StickerFileManager extends DocumentFileManager {
|
||||
private static Logger logger = LoggerFactory.getLogger(StickerFileManager.class);
|
||||
|
||||
public StickerFileManager(TLMessage msg, UserManager user, TelegramClient client) {
|
||||
super(msg, user, client);
|
||||
}
|
||||
@ -74,9 +83,21 @@ public class StickerFileManager extends DocumentFileManager {
|
||||
}
|
||||
|
||||
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();
|
||||
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"; }
|
||||
|
Loading…
Reference in New Issue
Block a user