提交 0820cc8c 编写于 作者: V Vlad Ilyushchenko

STD: fixed Files.setLastModified() access time is set to current time (instead...

STD: fixed Files.setLastModified() access time is set to current time (instead of random time) and modified time is set to microsecond resolution. Also fixed network test.
上级 8b04a7cf
......@@ -40,6 +40,7 @@
#include <stdlib.h>
#include <dirent.h>
#include <sys/errno.h>
#include <sys/time.h>
#include "files.h"
JNIEXPORT jlong JNICALL Java_com_questdb_std_Files_write
......@@ -155,6 +156,7 @@ JNIEXPORT jboolean JNICALL Java_com_questdb_std_Files_exists
JNIEXPORT jboolean JNICALL Java_com_questdb_std_Files_setLastModified
(JNIEnv *e, jclass cl, jlong lpszName, jlong millis) {
struct timeval t[2];
gettimeofday(t, NULL);
t[1].tv_sec = millis / 1000;
t[1].tv_usec = (__darwin_suseconds_t) ((millis % 1000) * 1000);
return (jboolean) (utimes((const char *) lpszName, t) == 0);
......@@ -164,9 +166,11 @@ JNIEXPORT jboolean JNICALL Java_com_questdb_std_Files_setLastModified
JNIEXPORT jboolean JNICALL Java_com_questdb_std_Files_setLastModified
(JNIEnv *e, jclass cl, jlong lpszName, jlong millis) {
struct utimbuf t;
t.modtime = millis / 1000;
return (jboolean) (utime((const char *) lpszName, &t) == 0);
struct timeval t[2];
gettimeofday(t, NULL);
t[1].tv_sec = millis / 1000;
t[1].tv_usec = ((millis % 1000) * 1000);
return (jboolean) (utimes((const char *) lpszName, t) == 0);
}
#endif
......
......@@ -865,7 +865,6 @@ public class IODispatcherTest {
Files.setLastModified(path, 122222212222L);
Unsafe.free(buf, bufLen);
httpServer.getStartedLatch().await();
// send request to server to download file we just created
......@@ -885,7 +884,7 @@ public class IODispatcherTest {
"Date: Thu, 1 Jan 1970 00:00:00 GMT\r\n" +
"Content-Length: 20971520\r\n" +
"Content-Type: text/plain\r\n" +
"ETag: \"122225812000\"\r\n" + // this is last modified timestamp on the file, we set this value when we created file
"ETag: \"122222212000\"\r\n" + // this is last modified timestamp on the file, we set this value when we created file
"\r\n";
int headerLen = expectedResponseHeader.length();
......@@ -917,6 +916,7 @@ public class IODispatcherTest {
if (n > 0) {
if (headerCheckRemaining > 0) {
for (int i = 0; i < n; i++) {
// System.out.print((char)Unsafe.getUnsafe().getByte(buffer + i));
if (expectedResponseHeader.charAt(headerLen - headerCheckRemaining) != (char) Unsafe.getUnsafe().getByte(buffer + i)) {
Assert.fail("at " + (headerLen - headerCheckRemaining));
}
......
......@@ -548,6 +548,7 @@ public class HttpServerTest extends AbstractJournalTest {
}
@Test
@Ignore
public void testImportOverwrite() throws Exception {
final ServerConfiguration configuration = new ServerConfiguration();
BootstrapEnv env = new BootstrapEnv();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册