Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
7cce979b
提交
7cce979b
authored
13 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Read-only databases in a zip file did not work when using the -baseDir option.
上级
3b138227
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
53 行增加
和
18 行删除
+53
-18
ConnectionInfo.java
h2/src/main/org/h2/engine/ConnectionInfo.java
+3
-0
FilePathZip.java
h2/src/main/org/h2/store/fs/FilePathZip.java
+6
-1
TestReadOnly.java
h2/src/test/org/h2/test/db/TestReadOnly.java
+37
-0
TestFileSystem.java
h2/src/test/org/h2/test/unit/TestFileSystem.java
+1
-1
FilePathZip2.java
h2/src/tools/org/h2/dev/fs/FilePathZip2.java
+6
-16
没有找到文件。
h2/src/main/org/h2/engine/ConnectionInfo.java
浏览文件 @
7cce979b
...
@@ -163,6 +163,9 @@ public class ConnectionInfo implements Cloneable {
...
@@ -163,6 +163,9 @@ public class ConnectionInfo implements Cloneable {
boolean
absolute
=
FileUtils
.
isAbsolute
(
name
);
boolean
absolute
=
FileUtils
.
isAbsolute
(
name
);
String
n
;
String
n
;
String
prefix
=
null
;
String
prefix
=
null
;
if
(
dir
.
endsWith
(
SysProperties
.
FILE_SEPARATOR
))
{
dir
=
dir
.
substring
(
0
,
dir
.
length
()
-
1
);
}
if
(
absolute
)
{
if
(
absolute
)
{
n
=
name
;
n
=
name
;
}
else
{
}
else
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/fs/FilePathZip.java
浏览文件 @
7cce979b
...
@@ -68,7 +68,12 @@ public class FilePathZip extends FilePath {
...
@@ -68,7 +68,12 @@ public class FilePathZip extends FilePath {
}
}
public
boolean
isAbsolute
()
{
public
boolean
isAbsolute
()
{
return
true
;
String
fileName
=
translateFileName
(
name
);
return
FilePath
.
get
(
fileName
).
isAbsolute
();
}
public
FilePath
unwrap
()
{
return
FilePath
.
get
(
name
.
substring
(
getScheme
().
length
()
+
1
));
}
}
public
boolean
isDirectory
()
{
public
boolean
isDirectory
()
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestReadOnly.java
浏览文件 @
7cce979b
...
@@ -9,14 +9,18 @@ package org.h2.test.db;
...
@@ -9,14 +9,18 @@ package org.h2.test.db;
import
java.io.File
;
import
java.io.File
;
import
java.io.RandomAccessFile
;
import
java.io.RandomAccessFile
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.ErrorCode
;
import
org.h2.dev.fs.FilePathZip2
;
import
org.h2.store.FileLister
;
import
org.h2.store.FileLister
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.tools.Backup
;
import
org.h2.tools.Server
;
/**
/**
* Test for the read-only database feature.
* Test for the read-only database feature.
...
@@ -36,6 +40,7 @@ public class TestReadOnly extends TestBase {
...
@@ -36,6 +40,7 @@ public class TestReadOnly extends TestBase {
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
return
;
}
}
testReadOnlyInZip
();
testReadOnlyTempTableResult
();
testReadOnlyTempTableResult
();
testReadOnlyConnect
();
testReadOnlyConnect
();
testReadOnlyDbCreate
();
testReadOnlyDbCreate
();
...
@@ -46,6 +51,38 @@ public class TestReadOnly extends TestBase {
...
@@ -46,6 +51,38 @@ public class TestReadOnly extends TestBase {
deleteDb
(
"readonly"
);
deleteDb
(
"readonly"
);
}
}
private
void
testReadOnlyInZip
()
throws
SQLException
{
deleteDb
(
"readonly"
);
String
dir
=
getBaseDir
();
Connection
conn
=
getConnection
(
"readonly"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE TEST(ID INT) AS SELECT X FROM SYSTEM_RANGE(1, 20)"
);
conn
.
close
();
Backup
.
execute
(
dir
+
"/readonly.zip"
,
dir
,
"readonly"
,
true
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:zip:"
+
dir
+
"/readonly.zip!/readonly"
,
getUser
(),
getPassword
());
conn
.
createStatement
().
execute
(
"select * from test where id=1"
);
conn
.
close
();
Server
server
=
Server
.
createTcpServer
(
"-tcpPort"
,
"9081"
,
"-baseDir"
,
dir
);
server
.
start
();
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9081/zip:readonly.zip!/readonly"
,
getUser
(),
getPassword
());
conn
.
createStatement
().
execute
(
"select * from test where id=1"
);
conn
.
close
();
FilePathZip2
.
register
();
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9081/zip2:readonly.zip!/readonly"
,
getUser
(),
getPassword
());
conn
.
createStatement
().
execute
(
"select * from test where id=1"
);
conn
.
close
();
}
finally
{
server
.
stop
();
}
FileUtils
.
deleteRecursive
(
dir
,
false
);
}
private
void
testReadOnlyTempTableResult
()
throws
SQLException
{
private
void
testReadOnlyTempTableResult
()
throws
SQLException
{
deleteDb
(
"readonly"
);
deleteDb
(
"readonly"
);
Connection
conn
=
getConnection
(
"readonly"
);
Connection
conn
=
getConnection
(
"readonly"
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/unit/TestFileSystem.java
浏览文件 @
7cce979b
...
@@ -199,7 +199,7 @@ public class TestFileSystem extends TestBase {
...
@@ -199,7 +199,7 @@ public class TestFileSystem extends TestBase {
deleteDb
(
"fsJar"
);
deleteDb
(
"fsJar"
);
for
(
String
f
:
FileUtils
.
newDirectoryStream
(
"zip:"
+
getBaseDir
()
+
"/fsJar.zip"
))
{
for
(
String
f
:
FileUtils
.
newDirectoryStream
(
"zip:"
+
getBaseDir
()
+
"/fsJar.zip"
))
{
assert
Tru
e
(
FileUtils
.
isAbsolute
(
f
));
assert
Fals
e
(
FileUtils
.
isAbsolute
(
f
));
assertTrue
(!
FileUtils
.
isDirectory
(
f
));
assertTrue
(!
FileUtils
.
isDirectory
(
f
));
assertTrue
(
FileUtils
.
size
(
f
)
>
0
);
assertTrue
(
FileUtils
.
size
(
f
)
>
0
);
assertTrue
(
f
.
endsWith
(
FileUtils
.
getName
(
f
)));
assertTrue
(
f
.
endsWith
(
FileUtils
.
getName
(
f
)));
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/dev/fs/FilePathZip2.java
浏览文件 @
7cce979b
...
@@ -96,10 +96,6 @@ public class FilePathZip2 extends FilePath {
...
@@ -96,10 +96,6 @@ public class FilePathZip2 extends FilePath {
}
}
}
}
// public boolean fileStartsWith(String fileName, String prefix) {
// return fileName.startsWith(prefix);
// }
public
long
lastModified
()
{
public
long
lastModified
()
{
return
0
;
return
0
;
}
}
...
@@ -110,7 +106,12 @@ public class FilePathZip2 extends FilePath {
...
@@ -110,7 +106,12 @@ public class FilePathZip2 extends FilePath {
}
}
public
boolean
isAbsolute
()
{
public
boolean
isAbsolute
()
{
return
true
;
String
fileName
=
translateFileName
(
name
);
return
FilePath
.
get
(
fileName
).
isAbsolute
();
}
public
FilePath
unwrap
()
{
return
FilePath
.
get
(
name
.
substring
(
getScheme
().
length
()
+
1
));
}
}
public
boolean
isDirectory
()
{
public
boolean
isDirectory
()
{
...
@@ -258,17 +259,6 @@ public class FilePathZip2 extends FilePath {
...
@@ -258,17 +259,6 @@ public class FilePathZip2 extends FilePath {
throw
DbException
.
getUnsupportedException
(
"write"
);
throw
DbException
.
getUnsupportedException
(
"write"
);
}
}
// public String unwrap(String fileName) {
// if (fileName.startsWith(PREFIX)) {
// fileName = fileName.substring(PREFIX.length());
// }
// int idx = fileName.indexOf('!');
// if (idx >= 0) {
// fileName = fileName.substring(0, idx);
// }
// return FileSystemDisk.expandUserHomeDirectory(fileName);
// }
private
String
getEntryName
()
{
private
String
getEntryName
()
{
int
idx
=
name
.
indexOf
(
'!'
);
int
idx
=
name
.
indexOf
(
'!'
);
String
fileName
;
String
fileName
;
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论