Don't use Unicode ellipsis character for filename

It will be replaced by three dots.
This commit is contained in:
FooIbar committed 2024-06-23 09:04:18 +08:00
1 parent 417a06e140
commit 176a802e96
3 files changed
+10 -6

No files matched your search

@@ -42,6 +42,7 @@ import com.hippo.ehviewer.util.FileUtils
import com.hippo.ehviewer.util.sendTo
import com.hippo.unifile.UniFile
import com.hippo.unifile.asUniFile
import com.hippo.unifile.ensureDirOrThrow
import com.hippo.unifile.openOutputStream
import com.hippo.unifile.sha1
import eu.kanade.tachiyomi.util.system.logcat
@@ -79,10 +80,10 @@ class SpiderDen(val info: GalleryInfo) {
mode = value
if (mode == SpiderQueen.MODE_DOWNLOAD) {
if (downloadDir == null) {
downloadDir = getGalleryDownloadDir(gid)?.takeIf { it.ensureDir() }
downloadDir = getGalleryDownloadDir(gid)!!.apply { ensureDirOrThrow() }
}
if (saveAsCbz && tempDownloadDir == null) {
tempDownloadDir = info.tempDownloadDir?.takeIf { it.ensureDir() }
tempDownloadDir = info.tempDownloadDir!!.apply { ensureDirOrThrow() }
}
}
}
@@ -306,7 +307,7 @@ class SpiderDen(val info: GalleryInfo) {
suspend fun initDownloadDir() {
downloadDir = getGalleryDownloadDir(gid) ?: (downloadLocation / info.putToDownloadDir())
check(downloadDir!!.ensureDir())
downloadDir!!.ensureDirOrThrow()
}
suspend fun writeComicInfo(fetchMetadata: Boolean = true) {
@@ -118,10 +118,10 @@ object FileUtils {
}
}
if (sizeInBytes > MAX_FILENAME_BYTES) {
do {
while (sizeInBytes > MAX_FILENAME_BYTES - 3) {
deleteCharAt(length / 2)
} while (sizeInBytes >= MAX_FILENAME_BYTES)
insert(length / 2, '…')
}
insert(length / 2, "...")
}
}
}
@@ -46,3 +46,6 @@ val Uri.displayPath: String?
}
return toString()
}
fun UniFile.ensureDirOrThrow() =
check(ensureDir()) { "Failed to create directory: ${uri.displayPath}" }