added a call upon creation to JsonAttachment to set attachmentStoragePath

This commit is contained in:
Carl Bingel 2020-02-09 20:44:14 +01:00
parent 8ccf5d0bc6
commit a0bb46b9e6

View file

@ -30,6 +30,7 @@ import org.asamk.signal.storage.protocol.JsonIdentityKeyStore;
import org.asamk.signal.storage.threads.ThreadInfo; import org.asamk.signal.storage.threads.ThreadInfo;
import org.asamk.signal.util.IOUtils; import org.asamk.signal.util.IOUtils;
import org.asamk.signal.util.Util; import org.asamk.signal.util.Util;
import org.asamk.signal.JsonAttachment;
import org.signal.libsignal.metadata.InvalidMetadataMessageException; import org.signal.libsignal.metadata.InvalidMetadataMessageException;
import org.signal.libsignal.metadata.InvalidMetadataVersionException; import org.signal.libsignal.metadata.InvalidMetadataVersionException;
import org.signal.libsignal.metadata.ProtocolDuplicateMessageException; import org.signal.libsignal.metadata.ProtocolDuplicateMessageException;
@ -144,7 +145,7 @@ public class Manager implements Signal {
this.dataPath = this.settingsPath + "/data"; this.dataPath = this.settingsPath + "/data";
this.attachmentsPath = this.settingsPath + "/attachments"; this.attachmentsPath = this.settingsPath + "/attachments";
this.avatarsPath = this.settingsPath + "/avatars"; this.avatarsPath = this.settingsPath + "/avatars";
JsonAttachment.setAttachmentStoragePath(this.attachmentsPath);
} }
public String getUsername() { public String getUsername() {
@ -1460,6 +1461,10 @@ public class Manager implements Signal {
return new File(attachmentsPath, attachmentId + ""); return new File(attachmentsPath, attachmentId + "");
} }
public String getAttachmentFilePath(long attachmentId) {
return attachmentsPath + File.separator + attachmentId;
}
private File retrieveAttachment(SignalServiceAttachmentPointer pointer) throws IOException, InvalidMessageException { private File retrieveAttachment(SignalServiceAttachmentPointer pointer) throws IOException, InvalidMessageException {
IOUtils.createPrivateDirectories(attachmentsPath); IOUtils.createPrivateDirectories(attachmentsPath);
return retrieveAttachment(pointer, getAttachmentFile(pointer.getId()), true); return retrieveAttachment(pointer, getAttachmentFile(pointer.getId()), true);