diff --git a/server-aws/src/main/kotlin/com/lightningkite/lightningserver/files/S3File.kt b/server-aws/src/main/kotlin/com/lightningkite/lightningserver/files/S3File.kt index d59bc5fd..6232fcf4 100644 --- a/server-aws/src/main/kotlin/com/lightningkite/lightningserver/files/S3File.kt +++ b/server-aws/src/main/kotlin/com/lightningkite/lightningserver/files/S3File.kt @@ -38,7 +38,7 @@ data class S3File(val system: S3FileSystem, val path: File) : FileObject { it.delimiter("/") token?.let { t -> it.continuationToken(t) } }.await() - results += r.contents().filter { !it.key().substringAfter(path.toString()).contains('/') } + results += r.contents().filter { !it.key().substringAfter(path.unixPath).contains('/') } .map { S3File(system, File(it.key())) } if (r.isTruncated) token = r.nextContinuationToken() else break @@ -53,7 +53,7 @@ data class S3File(val system: S3FileSystem, val path: File) : FileObject { try { system.s3Async.headObject { it.bucket(system.bucket) - it.key(path.toString()) + it.key(path.unixPath) }.await().let { FileInfo( type = ContentType(it.contentType()), diff --git a/server-testing/src/main/kotlin/com/lightningkite/lightningserver/files/FileSystemTests.kt b/server-testing/src/main/kotlin/com/lightningkite/lightningserver/files/FileSystemTests.kt index d586bcf0..70674608 100644 --- a/server-testing/src/main/kotlin/com/lightningkite/lightningserver/files/FileSystemTests.kt +++ b/server-testing/src/main/kotlin/com/lightningkite/lightningserver/files/FileSystemTests.kt @@ -14,9 +14,6 @@ import kotlinx.coroutines.withTimeout import kotlinx.serialization.encodeToString import org.junit.Assert.* import org.junit.Test -import kotlin.time.Duration -import kotlinx.datetime.Instant -import java.time.Clock import kotlin.test.assertContains import kotlin.time.Duration.Companion.hours import kotlin.time.Duration.Companion.seconds @@ -65,6 +62,17 @@ abstract class FileSystemTests { assertEquals(ContentType.Text.Plain, info!!.type) assertTrue(info.size > 0L) assertTrue(info.lastModified > beforeModify) + + // Testing with sub folders. + val secondFile = system.root.resolve("test/secondTest.txt") + val secondMessage = "Hello Second world!" + val secondBeforeModify = now().minus(120.seconds) + secondFile.put(HttpContent.Text(secondMessage, ContentType.Text.Plain)) + val secondInfo = secondFile.head() + assertNotNull(secondInfo) + assertEquals(ContentType.Text.Plain, secondInfo!!.type) + assertTrue(secondInfo.size > 0L) + assertTrue(secondInfo.lastModified > secondBeforeModify) } } diff --git a/server-testing/src/test/kotlin/com/lightningkite/lightningdb/test/InMemoryDatabaseTests.kt b/server-testing/src/test/kotlin/com/lightningkite/lightningdb/test/InMemoryDatabaseTests.kt index e7709a31..4abae885 100644 --- a/server-testing/src/test/kotlin/com/lightningkite/lightningdb/test/InMemoryDatabaseTests.kt +++ b/server-testing/src/test/kotlin/com/lightningkite/lightningdb/test/InMemoryDatabaseTests.kt @@ -1,7 +1,6 @@ -package com.lightningkite.lightningdb.test.com.lightningkite.lightningdb.test +package com.lightningkite.lightningdb.test import com.lightningkite.lightningdb.* -import com.lightningkite.lightningdb.test.* import com.lightningkite.lightningserver.TestSettings import com.lightningkite.lightningserver.cache.Cache import com.lightningkite.lightningserver.cache.CacheTest @@ -17,7 +16,6 @@ import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking import org.junit.Test import java.io.File -import kotlin.time.Duration import kotlin.test.assertEquals import kotlin.time.Duration.Companion.hours diff --git a/server-testing/src/test/kotlin/com/lightningkite/lightningserver/TestSettings.kt b/server-testing/src/test/kotlin/com/lightningkite/lightningserver/TestSettings.kt index dc051d20..0dbb7eb0 100644 --- a/server-testing/src/test/kotlin/com/lightningkite/lightningserver/TestSettings.kt +++ b/server-testing/src/test/kotlin/com/lightningkite/lightningserver/TestSettings.kt @@ -80,9 +80,8 @@ object TestSettings: ServerPathGroup(ServerPath.root) { com.lightningkite.lightningdb.prepareModels() Settings.populateDefaults() engine = LocalEngine(LocalCache) - - } + val sampleUser = GlobalScope.async(start = CoroutineStart.LAZY) { info.collection().insertOne(User( email = "test@test.com",