Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
zhangyongji
/
MRFramework
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6b71aaa3
authored
Dec 10, 2019
by
Sarkizz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整更新逻辑
parent
75aa1dcc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
38 deletions
+25
-38
MRFramework/MRFramework/FoundationManagers/HotUpdate/MRUpdateManager.swift
+25
-38
No files found.
MRFramework/MRFramework/FoundationManagers/HotUpdate/MRUpdateManager.swift
View file @
6b71aaa3
...
...
@@ -117,18 +117,16 @@ open class MRUpdateManager: NSObject {
/// 重置www文件夹。从bundle中覆盖沙盒的www
open
func
resetFilesFolder
(
_
completion
:
(()
->
Void
)?
=
nil
)
{
asyncIfNeeded
{
if
let
bundleWWW
=
self
.
bundleWWWURL
{
if
!
self
.
settings
.
sandboxSrc
.
isURLExists
(
true
)
{
self
.
settings
.
sandboxSrc
.
syncCreate
()
}
bundleWWW
.
syncCopy
(
to
:
self
.
settings
.
sandboxSrc
)
self
.
sandboxUpdateURL
.
syncDelete
()
self
.
sandboxBackupURL
.
syncDelete
()
if
let
bundleWWW
=
self
.
bundleWWWURL
{
if
!
self
.
settings
.
sandboxSrc
.
isURLExists
(
true
)
{
self
.
settings
.
sandboxSrc
.
syncCreate
()
}
completion
?()
bundleWWW
.
syncCopy
(
to
:
self
.
settings
.
sandboxSrc
)
self
.
sandboxUpdateURL
.
syncDelete
()
self
.
sandboxBackupURL
.
syncDelete
()
}
completion
?()
}
deinit
{
...
...
@@ -173,46 +171,34 @@ extension MRUpdateManager {
}
}
///
检查本地文件是否有更新。
///
根据传入类型更新本地文件。此方法总是同步执行
/// - Parameter type: 更新类型
/// - Parameter complate: 回调
public
func
checkL
ocalUpdate
(
_
type
:
UpdateType
,
public
func
l
ocalUpdate
(
_
type
:
UpdateType
,
complate
:
((
_
manager
:
MRUpdateManager
,
_
error
:
Error
?)
->
Void
)?)
{
switch
type
{
case
.
appUpgrade
:
if
let
bundleWWW
=
bundleWWWURL
{
asyncIfNeeded
{
var
error
:
Error
?
if
self
.
sandboxUpdateURL
.
isURLExists
(
true
)
{
error
=
self
.
sandboxUpdateURL
.
syncDelete
()
}
if
error
==
nil
&&
self
.
sandboxBackupURL
.
isURLExists
(
true
)
{
error
=
self
.
sandboxBackupURL
.
syncDelete
()
}
if
error
==
nil
{
error
=
bundleWWW
.
syncCopy
(
to
:
self
.
sandboxSrcURL
)
}
self
.
asyncInMain
{
complate
?(
self
,
error
)
}
var
error
:
Error
?
if
self
.
sandboxUpdateURL
.
isURLExists
(
true
)
{
error
=
self
.
sandboxUpdateURL
.
syncDelete
()
}
}
else
{
asyncInMain
{
complate
?(
self
,
self
.
error
(
code
:
-
1
,
msg
:
"目录路径错误"
))
if
error
==
nil
&&
self
.
sandboxBackupURL
.
isURLExists
(
true
)
{
error
=
self
.
sandboxBackupURL
.
syncDelete
()
}
}
case
.
silence
:
let
operations
=
{
self
.
updateFromLocal
{
(
error
)
in
self
.
asyncInMain
{
complate
?(
self
,
error
)
}
if
error
==
nil
{
error
=
bundleWWW
.
syncCopy
(
to
:
self
.
sandboxSrcURL
)
}
complate
?(
self
,
error
)
}
else
{
complate
?(
self
,
self
.
error
(
code
:
-
1
,
msg
:
"目录路径错误"
))
}
asyncIfNeeded
{
operations
()
case
.
silence
:
self
.
updateFromLocal
{
(
error
)
in
complate
?(
self
,
error
)
}
default
:
complate
?(
self
,
nil
)
break
}
}
...
...
@@ -351,6 +337,7 @@ extension MRUpdateManager {
fileURL
.
syncDelete
()
if
let
data
=
try
?
Data
(
contentsOf
:
info
.
downloadURL
),
data
.
md5
==
info
.
fileHash
,
data
.
syncWrite
(
to
:
fileURL
)
==
nil
{
progressBlock
(
p
)
}
else
{
...
...
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