Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_42566577
o2oa
提交
9ce17255
o2oa
项目概览
weixin_42566577
/
o2oa
与 Fork 源项目一致
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9ce17255
编写于
1月 08, 2021
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
处理zip中有中文文件解压丢失文件或乱码的问题
上级
2d36a19f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
89 addition
and
4 deletion
+89
-4
o2server/pom.xml
o2server/pom.xml
+11
-2
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/ZipTools.java
...src/main/java/com/x/base/core/project/tools/ZipTools.java
+76
-0
o2server/x_console/src/main/java/com/x/server/console/NodeAgent.java
...console/src/main/java/com/x/server/console/NodeAgent.java
+2
-2
未找到文件。
o2server/pom.xml
浏览文件 @
9ce17255
...
...
@@ -294,7 +294,7 @@
<groupId>
com.squareup
</groupId>
<artifactId>
javapoet
</artifactId>
</dependency>
<!-- dependency> <groupId>javax.visrec</groupId> <artifactId>visrec-api</artifactId>
<!-- dependency> <groupId>javax.visrec</groupId> <artifactId>visrec-api</artifactId>
</dependency -->
<dependency>
<groupId>
com.github.neuroph
</groupId>
...
...
@@ -348,6 +348,10 @@
<groupId>
javax.activation
</groupId>
<artifactId>
activation
</artifactId>
</dependency>
<dependency>
<groupId>
net.lingala.zip4j
</groupId>
<artifactId>
zip4j
</artifactId>
</dependency>
</dependencies>
<build>
...
...
@@ -785,7 +789,7 @@
<artifactId>
javapoet
</artifactId>
<version>
1.11.1
</version>
</dependency>
<!--dependency> <groupId>javax.visrec</groupId> <artifactId>visrec-api</artifactId>
<!--dependency> <groupId>javax.visrec</groupId> <artifactId>visrec-api</artifactId>
<version>20200316</version> </dependency -->
<dependency>
<groupId>
com.github.neuroph
</groupId>
...
...
@@ -1002,6 +1006,11 @@
<artifactId>
x_workschedu_core_entity
</artifactId>
<version>
5.3
</version>
</dependency>
<dependency>
<groupId>
net.lingala.zip4j
</groupId>
<artifactId>
zip4j
</artifactId>
<version>
2.3.2
</version>
</dependency>
</dependencies>
</dependencyManagement>
<repositories>
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/ZipTools.java
0 → 100644
浏览文件 @
9ce17255
package
com.x.base.core.project.tools
;
import
net.lingala.zip4j.ZipFile
;
import
net.lingala.zip4j.model.ExtraDataRecord
;
import
net.lingala.zip4j.model.FileHeader
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.File
;
import
java.nio.ByteBuffer
;
import
java.nio.charset.Charset
;
import
java.util.List
;
public
class
ZipTools
{
public
static
void
unZip
(
File
source
,
List
<
String
>
subs
,
File
dist
,
boolean
asNew
,
Charset
charset
)
{
try
{
ZipFile
zipFile
=
new
ZipFile
(
source
);
if
(
charset
==
null
){
charset
=
DefaultCharset
.
charset
;
}
zipFile
.
setCharset
(
charset
);
List
<
FileHeader
>
fileHeaderList
=
zipFile
.
getFileHeaders
();
for
(
FileHeader
fileHeader
:
fileHeaderList
){
if
(
isFromExtraData
(
fileHeader
)
&&
DefaultCharset
.
charset
.
name
()
==
charset
.
name
()){
unZip
(
source
,
subs
,
dist
,
asNew
,
DefaultCharset
.
charset_gbk
);
return
;
}
String
name
=
fileHeader
.
getFileName
();
//System.out.println(name);
if
(
name
.
length
()
<
2
)
{
continue
;
}
if
(
subs
!=
null
)
{
boolean
flag
=
false
;
for
(
String
sub
:
subs
)
{
if
(
StringUtils
.
startsWith
(
name
,
sub
))
{
flag
=
true
;
break
;
}
}
if
(
flag
)
{
continue
;
}
}
if
(
fileHeader
.
isDirectory
())
{
File
dir
=
new
File
(
dist
,
name
);
if
(
dir
.
exists
()
&&
name
.
indexOf
(
"/"
)
==
name
.
lastIndexOf
(
"/"
)
&&
asNew
)
{
FileUtils
.
cleanDirectory
(
dir
);
}
FileUtils
.
forceMkdir
(
dir
);
}
else
{
zipFile
.
extractFile
(
fileHeader
,
dist
.
getAbsolutePath
());
}
}
fileHeaderList
.
clear
();
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
}
public
static
boolean
isFromExtraData
(
FileHeader
fileHeader
)
{
if
(
fileHeader
.
getExtraDataRecords
()!=
null
){
for
(
ExtraDataRecord
extraDataRecord
:
fileHeader
.
getExtraDataRecords
())
{
long
identifier
=
extraDataRecord
.
getHeader
();
if
(
identifier
==
0x7075
)
{
byte
[]
bytes
=
extraDataRecord
.
getData
();
ByteBuffer
buffer
=
ByteBuffer
.
wrap
(
bytes
);
byte
version
=
buffer
.
get
();
assert
(
version
==
1
);
return
true
;
}
}
}
return
false
;
}
}
o2server/x_console/src/main/java/com/x/server/console/NodeAgent.java
浏览文件 @
9ce17255
...
...
@@ -378,7 +378,7 @@ public class NodeAgent extends Thread {
FileTools
.
forceMkdir
(
dist
);
}
List
<
String
>
subs
=
new
ArrayList
<>();
JarTools
.
unjar
(
zipFile
,
subs
,
dist
,
asNew
);
ZipTools
.
unZip
(
zipFile
,
subs
,
dist
,
asNew
,
null
);
FileUtils
.
cleanDirectory
(
tempFile
);
logger
.
print
(
"upload resource {} success!"
,
fileName
);
...
...
@@ -655,7 +655,7 @@ public class NodeAgent extends Thread {
FileUtils
.
writeByteArrayToFile
(
zipFile
,
bytes
);
File
dist
=
Config
.
dir_custom
(
true
);
List
<
String
>
subs
=
new
ArrayList
<>();
JarTools
.
unjar
(
zipFile
,
subs
,
dist
,
false
);
ZipTools
.
unZip
(
zipFile
,
subs
,
dist
,
false
,
null
);
FileUtils
.
cleanDirectory
(
tempFile
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录