fix assets paths

3
Timo Bryant 2024-01-04 12:20:46 +01:00
parent 97b5444159
commit d23b4f472c
4 changed files with 13 additions and 4 deletions

View File

@ -21,7 +21,7 @@ import kotlin.io.path.exists
import kotlin.io.path.outputStream
private val Log = KotlinLogging.logger { }
class FilesystemAssetManager : AssetManager {
class FilesystemAssetManager: AssetManager {
override suspend fun assets(name: String): Assets {
val path = createAssetsPath(name)
withContext(Dispatchers.IO) {
@ -38,7 +38,7 @@ class FilesystemAssetManager : AssetManager {
}
private fun createAssetsPath(name: String): Path {
return Paths.get("$name.assets.d").toAbsolutePath()
return Paths.get(name).parent.resolve("$name.assets.d").toAbsolutePath()
}
}

View File

@ -48,6 +48,10 @@ class FilesystemProject(
private val assetManager: AssetManager by inject()
private val resourceFactory: ResourceFactory by inject()
override fun resolveName(name: String): String {
return basePath.resolve(name).toAbsolutePath().toString()
}
override suspend fun assets(documentName: String): Assets {
return assetManager.assets(documentName)
}

View File

@ -10,7 +10,9 @@ interface Project {
val name: String
val displayName: String
val documentNames: List<String>
suspend fun assets(documentName: String): Assets
fun resolveName(name: String): String
suspend fun assets(documentName: String): Assets
suspend fun resource(name: String): Resource?
}

View File

@ -29,6 +29,9 @@ class Corpus(private val project: Project): KoinComponent {
private val resourceFactory: ResourceFactory by inject()
suspend fun document(name: String): Document {
return Document(name, listOf(project.resource(name)!!))
return Document(
project.resolveName(name),
listOf(project.resource(name)!!)
)
}
}