Download Bug fix

Added favorite to TagChip
Improved eyeblink recognition
This commit is contained in:
tom5079
2020-09-26 09:07:52 +09:00
parent fca42c79a8
commit a973cdfe0b
11 changed files with 77 additions and 55 deletions

View File

@@ -200,24 +200,18 @@ class Cache private constructor(context: Context, val galleryID: Int) : ContextW
fun moveToDownload() = CoroutineScope(Dispatchers.IO).launch {
val downloadFolder = downloadFolder ?: return@launch
if (downloadFolder.getChild(".metadata").exists())
val cacheMetadata = cacheFolder.getChild(".metadata")
val downloadMetadata = downloadFolder.getChild(".metadata")
if (downloadMetadata.exists() || !cacheMetadata.exists())
return@launch
metadata.imageList?.forEach { imageName ->
imageName ?: return@forEach
val target = downloadFolder.getChild(imageName)
val source = cacheFolder.getChild(imageName)
if (!source.exists() || target.exists())
return@forEach
if (cacheMetadata.exists()) {
kotlin.runCatching {
if (!target.exists())
target.createNewFile()
downloadMetadata.createNewFile()
downloadMetadata.writeText(Json.encodeToString(metadata))
target.outputStream()?.use { target -> source.inputStream()?.use { source ->
source.copyTo(target)
} }
cacheMetadata.delete()
}
}
@@ -236,19 +230,22 @@ class Cache private constructor(context: Context, val galleryID: Int) : ContextW
}
}
val cacheMetadata = cacheFolder.getChild(".metadata")
val downloadMetadata = downloadFolder.getChild(".metadata")
metadata.imageList?.forEach { imageName ->
imageName ?: return@forEach
val target = downloadFolder.getChild(imageName)
val source = cacheFolder.getChild(imageName)
if (!source.exists() || target.exists())
return@forEach
if (cacheMetadata.exists() && !downloadMetadata.exists()) {
kotlin.runCatching {
if (!downloadMetadata.exists())
downloadMetadata.createNewFile()
if (!target.exists())
target.createNewFile()
downloadMetadata.writeText(Json.encodeToString(metadata))
cacheMetadata.delete()
target.outputStream()?.use { target -> source.inputStream()?.use { source ->
source.copyTo(target)
} }
}
}
cacheFolder.delete()
}
}