mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-22 08:46:15 +00:00
Preparations for caching downloaded files.
This commit is contained in:
parent
ffddfe68d1
commit
b4c50a0163
@ -54,6 +54,7 @@ public abstract class AbstractMediaFileManager {
|
||||
public abstract String getExtension();
|
||||
public boolean isEmpty() { return isEmpty; }
|
||||
public boolean isDownloaded() { return new File(getTargetPathAndFilename()).isFile(); }
|
||||
public boolean isDownloading() { return new File(getTargetPathAndFilename() + ".downloading").isFile(); }
|
||||
public abstract void download() throws RpcErrorException, IOException;
|
||||
public static void throwUnexpectedObjectError(Object o) {
|
||||
throw new RuntimeException("Unexpected " + o.getClass().getName());
|
||||
|
@ -47,19 +47,10 @@ public class StickerFileManager extends DocumentFileManager {
|
||||
public StickerFileManager(TLMessage msg, UserManager user, TelegramClient client) {
|
||||
super(msg, user, client);
|
||||
}
|
||||
/* TLAbsDocument d = ((TLMessageMediaDocument)msg.getMedia()).getDocument();
|
||||
if (d instanceof TLDocument) {
|
||||
this.doc = (TLDocument)d;
|
||||
} else if (d instanceof TLDocumentEmpty) {
|
||||
this.isEmpty = true;
|
||||
} else {
|
||||
throwUnexpectedObjectError(d);
|
||||
}
|
||||
}*/
|
||||
|
||||
public boolean isSticker() { return true; }
|
||||
|
||||
public String getTargetFilename() {
|
||||
private String getFilenameBase() {
|
||||
TLDocumentAttributeSticker sticker = null;
|
||||
for(TLAbsDocumentAttribute attr : doc.getAttributes()) {
|
||||
if (attr instanceof TLDocumentAttributeSticker) {
|
||||
@ -75,11 +66,13 @@ public class StickerFileManager extends DocumentFileManager {
|
||||
}
|
||||
file.append("_");
|
||||
file.append(sticker.getAlt().hashCode());
|
||||
file.append(".");
|
||||
file.append(getExtension());
|
||||
return file.toString();
|
||||
}
|
||||
|
||||
public String getTargetFilename() {
|
||||
return getFilenameBase() + "." + getExtension();
|
||||
}
|
||||
|
||||
public String getTargetPath() {
|
||||
String path = Config.FILE_BASE + File.separatorChar + Config.FILE_STICKER_BASE + File.separatorChar;
|
||||
new File(path).mkdirs();
|
||||
|
Loading…
Reference in New Issue
Block a user