Hold strong reference in RemoteFileImpl.contact

This commit is contained in:
Him188 2021-08-02 13:52:48 +08:00
parent 814718403e
commit 2ae12f4d37

View File

@ -100,11 +100,9 @@ internal fun RemoteFile.checkIsImpl(): RemoteFileImpl {
} }
internal class RemoteFileImpl( internal class RemoteFileImpl(
contact: Group, override val contact: Group,
override val path: String, // absolute override val path: String, // absolute
) : RemoteFile { ) : RemoteFile {
private val contactRef by contact.weakRef()
override val contact get() = contactRef ?: error("RemoteFile is closed due to Contact closed.")
constructor(contact: Group, parent: String, name: String) : this(contact, fs.normalize(parent, name)) constructor(contact: Group, parent: String, name: String) : this(contact, fs.normalize(parent, name))