Открыть боковую панель
Aurora OS
Kotlin Multiplatform
Libraries
ktor
Коммиты
f7317b30
Не подтверждена
Коммит
f7317b30
создал
Авг 11, 2022
по автору
Rustam
Зафиксировано автором
GitHub
Авг 11, 2022
Просмотр файлов
KTOR-4707 Fix check for existence in LocalFileContent (#3117)
владелец
1d419232
Изменения
2
Скрыть пробелы
Построчно
Рядом
ktor-server/ktor-server-core/jvm/src/io/ktor/server/http/content/LocalFileContent.kt
Просмотр файла @
f7317b30
...
...
@@ -25,10 +25,10 @@ public class LocalFileContent(
override
val
contentLength
:
Long
get
()
=
file
.
length
()
init
{
val
lastModifiedVersion
=
file
.
lastModified
()
if
(
lastModifiedVersion
==
0L
)
{
if
(!
file
.
exists
())
{
throw
IOException
(
"No such file ${file.absolutePath}"
)
}
else
{
val
lastModifiedVersion
=
file
.
lastModified
()
versions
+=
LastModifiedVersion
(
lastModifiedVersion
)
}
}
...
...
ktor-server/ktor-server-core/jvm/test/io/ktor/tests/http/content/LocalFileContentTest.kt
0 → 100644
Просмотр файла @
f7317b30
/*
* Copyright 2014-2022 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
package
io.ktor.tests.http.content
import
io.ktor.server.http.content.*
import
java.io.*
import
kotlin.test.*
class
LocalFileContentTest
{
@Test
fun
testCreateWithFile
()
{
val
file
=
File
.
createTempFile
(
"test"
,
"txt"
)
LocalFileContent
(
file
)
}
@Test
fun
testCreateWithFileZeroLastModifiedDate
()
{
val
file
=
File
.
createTempFile
(
"test-zero-date"
,
"txt"
)
file
.
setLastModified
(
0
)
LocalFileContent
(
file
)
}
@Test
fun
testCreateWithNonExistingFile
()
{
val
file
=
File
(
"test-doesnt-exist"
,
"txt"
)
assertFailsWith
<
IOException
>
{
LocalFileContent
(
file
)
}
}
}
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать