Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setup-manager
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
setup-manager
Commits
c6b3eac6
Commit
c6b3eac6
authored
Oct 29, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改登录鉴权时间
parent
b88e72a2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
9 deletions
+89
-9
setup-project-manager/src/main/java/com/mortals/xhx/common/utils/ZipUtils.java
.../src/main/java/com/mortals/xhx/common/utils/ZipUtils.java
+81
-6
setup-project-manager/src/main/java/com/mortals/xhx/module/setup/service/impl/SetupProjectServiceImpl.java
...hx/module/setup/service/impl/SetupProjectServiceImpl.java
+8
-3
No files found.
setup-project-manager/src/main/java/com/mortals/xhx/common/utils/ZipUtils.java
View file @
c6b3eac6
package
com.mortals.xhx.common.utils
;
import
cn.hutool.core.compress.Gzip
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.util.ZipUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.compress.archivers.tar.TarArchiveEntry
;
import
org.apache.commons.compress.archivers.tar.TarArchiveInputStream
;
import
org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream
;
import
org.apache.commons.io.IOUtils
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.*
;
import
java.util.HashSet
;
import
java.util.Set
;
import
java.util.zip.GZIPInputStream
;
@Slf4j
public
class
ZipUtils
{
...
...
@@ -191,12 +191,87 @@ public class ZipUtils {
}
public
static
void
main
(
String
[]
args
)
{
private
static
final
int
BUFFER_SIZE
=
1024
;
/**
* 解压 gzip 文件
*
* @param input
* @param output
*
*/
public
static
void
decompressGzip
(
File
input
,
File
output
)
throws
IOException
{
try
(
GZIPInputStream
in
=
new
GZIPInputStream
(
new
FileInputStream
(
input
)))
{
try
(
FileOutputStream
out
=
new
FileOutputStream
(
output
))
{
byte
[]
buffer
=
new
byte
[
BUFFER_SIZE
];
int
len
;
while
((
len
=
in
.
read
(
buffer
))
!=
-
1
)
{
out
.
write
(
buffer
,
0
,
len
);
}
}
}
}
/**
* 解压 tar.gz 文件到指定目录
*
* @param tarGzFile tar.gz 文件路径
* @param destDir 解压到 destDir 目录,如果没有则自动创建
*
*/
public
static
void
extractTarGZ
(
File
tarGzFile
,
String
destDir
)
throws
IOException
{
GzipCompressorInputStream
gzipIn
=
new
GzipCompressorInputStream
(
new
FileInputStream
(
tarGzFile
));
try
(
TarArchiveInputStream
tarIn
=
new
TarArchiveInputStream
(
gzipIn
))
{
TarArchiveEntry
entry
;
while
((
entry
=
(
TarArchiveEntry
)
tarIn
.
getNextEntry
())
!=
null
)
{
if
(
entry
.
isDirectory
())
{
File
f
=
new
File
(
destDir
+
"/"
+
entry
.
getName
());
boolean
created
=
f
.
mkdirs
();
if
(!
created
)
{
System
.
out
.
printf
(
"Unable to create directory '%s', during extraction of archive contents.\n"
,
f
.
getAbsolutePath
());
}
}
else
{
int
count
;
byte
[]
data
=
new
byte
[
BUFFER_SIZE
];
new
File
(
destDir
+
"/"
+
entry
.
getName
())
File
parent
=
curfile
.
getParentFile
();
log
.
info
(
"***文件保存的路径"
+
curfile
.
getAbsolutePath
());
if
(!
parent
.
exists
())
{
parent
.
mkdirs
();
}
FileOutputStream
fos
=
new
FileOutputStream
(
destDir
+
"/"
+
entry
.
getName
(),
false
);
try
(
BufferedOutputStream
dest
=
new
BufferedOutputStream
(
fos
,
BUFFER_SIZE
))
{
while
((
count
=
tarIn
.
read
(
data
,
0
,
BUFFER_SIZE
))
!=
-
1
)
{
dest
.
write
(
data
,
0
,
count
);
}
}
}
}
}
}
public
static
void
main
(
String
[]
args
)
throws
IOException
{
String
fileName
=
"E:\\pic\\zip\\base-manager.tar.gz"
;
String
unZipPath
=
"E:\\pic\\zip\\"
;
ZipUtils
.
unGzip
(
fileName
,
unZipPath
);
//ZipUtils.unGzip(fileName, unZipPath);
File
file
=
new
File
(
fileName
);
/* File file = new File(fileName);
;
byte[] bytes = ZipUtil.unGzip(FileUtil.readBytes(file));*/
ZipUtils
.
extractTarGZ
(
file
,
unZipPath
);
}
...
...
setup-project-manager/src/main/java/com/mortals/xhx/module/setup/service/impl/SetupProjectServiceImpl.java
View file @
c6b3eac6
package
com.mortals.xhx.module.setup.service.impl
;
import
cn.hutool.Hutool
;
import
cn.hutool.core.compress.Gzip
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.util.CharsetUtil
;
import
cn.hutool.core.util.RuntimeUtil
;
...
...
@@ -103,13 +104,17 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec
throw
new
AppException
(
"请上传项目工程文件!"
);
}
InputStream
inputStream
=
FileUtil
.
getInputStream
(
file
);
//
InputStream inputStream = FileUtil.getInputStream(file);
///Hutoo.unGzip(inputStream, setupProjectEntity.getProjectPath());
//Hutool
ZipUtils
.
unGzip
(
inputStream
,
setupProjectEntity
.
getProjectPath
());
try
{
ZipUtils
.
extractTarGZ
(
file
,
setupProjectEntity
.
getProjectPath
());
}
catch
(
IOException
e
)
{
log
.
error
(
"解压失败!{}"
,
e
.
getMessage
());
}
// ZipUtils.unGzip(inputStream, setupProjectEntity.getProjectPath());
String
publicPath
=
setupProjectEntity
.
getProjectPath
()
+
ProductDisEnum
.
getByValue
(
setupProjectEntity
.
getProjectCode
()).
getValue
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment