commit 9973da1021908ff61322f90e59398fd65f7dd7ce parent c31e6fd0c2e16546137d596d71ea9d2d960a993b Author: rhunk <101876869+rhunk@users.noreply.github.com> Date: Tue, 28 May 2024 23:59:15 +0200 fix(file_wrapper): default value Diffstat:
M | common/src/main/kotlin/me/rhunk/snapenhance/common/bridge/InternalFileWrapper.kt | | | 8 | +++++--- |
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/bridge/InternalFileWrapper.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/bridge/InternalFileWrapper.kt @@ -8,9 +8,11 @@ open class InternalFileWrapper( val defaultValue: String? = null ): FileHandleWrapper(lazy { fileHandleManager.getFileHandle(FileHandleScope.INTERNAL.key, fileType.key)!! }) { override fun readBytes(): ByteArray { - val bytes = super.readBytes() - if (bytes.isEmpty()) { - defaultValue?.let { writeBytes(it.toByteArray()) } + if (!exists()) { + defaultValue?.toByteArray(Charsets.UTF_8)?.let { + writeBytes(it) + return it + } } return super.readBytes() }