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
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
17 deletions
+4
-17
MRFramework/MRFramework/FoundationManagers/HotUpdate/MRUpdateManager.swift
+4
-17
No files found.
MRFramework/MRFramework/FoundationManagers/HotUpdate/MRUpdateManager.swift
View file @
6b71aaa3
...
@@ -117,7 +117,6 @@ open class MRUpdateManager: NSObject {
...
@@ -117,7 +117,6 @@ open class MRUpdateManager: NSObject {
/// 重置www文件夹。从bundle中覆盖沙盒的www
/// 重置www文件夹。从bundle中覆盖沙盒的www
open
func
resetFilesFolder
(
_
completion
:
(()
->
Void
)?
=
nil
)
{
open
func
resetFilesFolder
(
_
completion
:
(()
->
Void
)?
=
nil
)
{
asyncIfNeeded
{
if
let
bundleWWW
=
self
.
bundleWWWURL
{
if
let
bundleWWW
=
self
.
bundleWWWURL
{
if
!
self
.
settings
.
sandboxSrc
.
isURLExists
(
true
)
{
if
!
self
.
settings
.
sandboxSrc
.
isURLExists
(
true
)
{
self
.
settings
.
sandboxSrc
.
syncCreate
()
self
.
settings
.
sandboxSrc
.
syncCreate
()
...
@@ -129,7 +128,6 @@ open class MRUpdateManager: NSObject {
...
@@ -129,7 +128,6 @@ open class MRUpdateManager: NSObject {
}
}
completion
?()
completion
?()
}
}
}
deinit
{
deinit
{
if
let
observer
=
backgroundObserver
{
if
let
observer
=
backgroundObserver
{
...
@@ -173,15 +171,14 @@ extension MRUpdateManager {
...
@@ -173,15 +171,14 @@ extension MRUpdateManager {
}
}
}
}
///
检查本地文件是否有更新。
///
根据传入类型更新本地文件。此方法总是同步执行
/// - Parameter type: 更新类型
/// - Parameter type: 更新类型
/// - Parameter complate: 回调
/// - Parameter complate: 回调
public
func
checkL
ocalUpdate
(
_
type
:
UpdateType
,
public
func
l
ocalUpdate
(
_
type
:
UpdateType
,
complate
:
((
_
manager
:
MRUpdateManager
,
_
error
:
Error
?)
->
Void
)?)
{
complate
:
((
_
manager
:
MRUpdateManager
,
_
error
:
Error
?)
->
Void
)?)
{
switch
type
{
switch
type
{
case
.
appUpgrade
:
case
.
appUpgrade
:
if
let
bundleWWW
=
bundleWWWURL
{
if
let
bundleWWW
=
bundleWWWURL
{
asyncIfNeeded
{
var
error
:
Error
?
var
error
:
Error
?
if
self
.
sandboxUpdateURL
.
isURLExists
(
true
)
{
if
self
.
sandboxUpdateURL
.
isURLExists
(
true
)
{
error
=
self
.
sandboxUpdateURL
.
syncDelete
()
error
=
self
.
sandboxUpdateURL
.
syncDelete
()
...
@@ -192,27 +189,16 @@ extension MRUpdateManager {
...
@@ -192,27 +189,16 @@ extension MRUpdateManager {
if
error
==
nil
{
if
error
==
nil
{
error
=
bundleWWW
.
syncCopy
(
to
:
self
.
sandboxSrcURL
)
error
=
bundleWWW
.
syncCopy
(
to
:
self
.
sandboxSrcURL
)
}
}
self
.
asyncInMain
{
complate
?(
self
,
error
)
complate
?(
self
,
error
)
}
}
}
else
{
}
else
{
asyncInMain
{
complate
?(
self
,
self
.
error
(
code
:
-
1
,
msg
:
"目录路径错误"
))
complate
?(
self
,
self
.
error
(
code
:
-
1
,
msg
:
"目录路径错误"
))
}
}
}
case
.
silence
:
case
.
silence
:
let
operations
=
{
self
.
updateFromLocal
{
(
error
)
in
self
.
updateFromLocal
{
(
error
)
in
self
.
asyncInMain
{
complate
?(
self
,
error
)
complate
?(
self
,
error
)
}
}
}
}
asyncIfNeeded
{
operations
()
}
default
:
default
:
complate
?(
self
,
nil
)
break
break
}
}
}
}
...
@@ -351,6 +337,7 @@ extension MRUpdateManager {
...
@@ -351,6 +337,7 @@ extension MRUpdateManager {
fileURL
.
syncDelete
()
fileURL
.
syncDelete
()
if
let
data
=
try
?
Data
(
contentsOf
:
info
.
downloadURL
),
if
let
data
=
try
?
Data
(
contentsOf
:
info
.
downloadURL
),
data
.
md5
==
info
.
fileHash
,
data
.
syncWrite
(
to
:
fileURL
)
==
nil
{
data
.
syncWrite
(
to
:
fileURL
)
==
nil
{
progressBlock
(
p
)
progressBlock
(
p
)
}
else
{
}
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