Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
huangzhicong
/
SmartCanteen
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a7ac41e3
authored
Dec 12, 2019
by
patpat
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into test
parents
225fbc6d
ec0b4fe8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
21 deletions
+20
-21
app/src/main/java/com/bgycc/smartcanteen/action/LogAction.kt
+20
-21
No files found.
app/src/main/java/com/bgycc/smartcanteen/action/LogAction.kt
View file @
a7ac41e3
package
com.bgycc.smartcanteen.action
import
com.bgycc.smartcanteen.App
import
com.bgycc.smartcanteen.BuildConfig
import
com.bgycc.smartcanteen.server.http.MainHttpClient
import
com.bgycc.smartcanteen.util.LogUtil
import
com.blankj.utilcode.util.FileIOUtils
import
com.blankj.utilcode.util.FileUtils
import
com.blankj.utilcode.util.PathUtils
import
com.blankj.utilcode.util.ZipUtils
...
...
@@ -44,26 +41,28 @@ object LogAction : Action(ActionEnum.LOG_PULL.name) {
}
Thread
{
state
=
State
.
STARTED
val
logZipFile
=
File
(
PathUtils
.
getExternalAppCachePath
(),
"upload/log.zip"
)
val
logUploadDir
=
File
(
PathUtils
.
getExternalAppCachePath
(),
"upload/log"
)
FileUtils
.
delete
(
logZipFile
)
FileUtils
.
deleteDir
(
logUploadDir
)
logUploadDir
.
mkdirs
()
try
{
state
=
State
.
STARTED
val
logZipFile
=
File
(
PathUtils
.
getExternalAppCachePath
(),
"upload/log.zip"
)
val
logUploadDir
=
File
(
PathUtils
.
getExternalAppCachePath
(),
"upload/log"
)
FileUtils
.
delete
(
logZipFile
)
FileUtils
.
deleteDir
(
logUploadDir
)
logUploadDir
.
mkdirs
()
val
logDir
=
when
(
type
)
{
"system"
->
File
(
PathUtils
.
getExternalStoragePath
(),
"boot_log"
)
else
->
File
(
PathUtils
.
getExternalAppCachePath
(),
"log"
)
}
FileUtils
.
listFilesInDir
(
logDir
).
forEach
{
val
date
=
Date
(
it
.
lastModified
())
if
(
date
>=
startTime
&&
date
<=
endTime
)
{
FileUtils
.
copyFile
(
it
,
File
(
logUploadDir
,
it
.
name
))
val
logDir
=
when
(
type
)
{
"system"
->
File
(
PathUtils
.
getExternalStoragePath
(),
"boot_log"
)
else
->
File
(
PathUtils
.
getExternalAppCachePath
(),
"log"
)
}
}
ZipUtils
.
zipFile
(
logUploadDir
,
logZipFile
)
FileUtils
.
deleteDir
(
logUploadDir
)
MainHttpClient
.
uploadLog
(
logZipFile
,
"$type${formatSrc.format(startTime)}${formatSrc.format(endTime)}${App.getDeviceSN()}.zip"
)
FileUtils
.
listFilesInDir
(
logDir
)
?.
forEach
{
val
date
=
Date
(
it
.
lastModified
())
if
(
date
>=
startTime
&&
date
<=
endTime
)
{
FileUtils
.
copyFile
(
it
,
File
(
logUploadDir
,
it
.
name
))
}
}
ZipUtils
.
zipFile
(
logUploadDir
,
logZipFile
)
FileUtils
.
deleteDir
(
logUploadDir
)
MainHttpClient
.
uploadLog
(
logZipFile
,
"$type${formatSrc.format(startTime)}${formatSrc.format(endTime)}${App.getDeviceSN()}.zip"
)
}
catch
(
e
:
Exception
)
{}
state
=
State
.
INITED
}.
start
()
}
catch
(
e
:
Exception
)
{}
...
...
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