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
dc7ad5d5
authored
Dec 04, 2019
by
Sarkizz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修正更新逻辑
parent
c81b5c4d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
MRFramework/MRFramework/FoundationManagers/HotUpdate/MRUpdateManager.swift
+15
-6
No files found.
MRFramework/MRFramework/FoundationManagers/HotUpdate/MRUpdateManager.swift
View file @
dc7ad5d5
...
...
@@ -116,7 +116,7 @@ open class MRUpdateManager: NSObject {
}
/// 重置www文件夹。从bundle中覆盖沙盒的www
open
func
resetFilesFolder
()
{
open
func
resetFilesFolder
(
_
completion
:
(()
->
Void
)?
=
nil
)
{
asyncIfNeeded
{
if
let
bundleWWW
=
self
.
bundleWWWURL
{
if
!
self
.
settings
.
sandboxSrc
.
isURLExists
(
true
)
{
...
...
@@ -127,6 +127,7 @@ open class MRUpdateManager: NSObject {
self
.
sandboxUpdateURL
.
syncDelete
()
self
.
sandboxBackupURL
.
syncDelete
()
}
completion
?()
}
}
...
...
@@ -219,7 +220,11 @@ extension MRUpdateManager {
/// 移除backup文件夹,并且从update文件夹中更新www文件
/// - Parameter complate: 回调
public
func
updateFromLocal
(
_
complate
:((
_
error
:
Error
?)
->
Void
)?)
{
sandboxBackupURL
.
syncDelete
()
if
sandboxBackupURL
.
isURLExists
()
{
sandboxBackupURL
.
syncDeleteItems
(
filter
:
nil
)
}
else
{
sandboxBackupURL
.
syncCreate
()
}
if
let
error
=
sandboxWWWURL
.
syncMoveItems
(
to
:
sandboxBackupURL
)
{
complate
?(
error
)
}
else
{
...
...
@@ -235,9 +240,11 @@ extension MRUpdateManager {
/// 检查传入文件路径的完整性,如果不完整,从bundle中获取www覆盖沙盒中的www
/// - Parameter file: 需要检查的文件路径
public
func
recoverFromBundleIfFileIncomplete
(
_
file
:
URL
)
{
public
func
recoverFromBundleIfFileIncomplete
(
_
file
:
URL
,
completion
:
(()
->
Void
)?
=
nil
)
{
if
!
checkFilesIntegrity
(
file
)
{
resetFilesFolder
()
resetFilesFolder
(
completion
)
}
else
{
completion
?()
}
}
}
...
...
@@ -317,7 +324,7 @@ extension MRUpdateManager {
var
isUpdateError
=
false
for
i
in
0
..<
infos
.
count
{
let
info
=
infos
[
i
]
let
p
=
Float
(
i
)
/
Float
(
infos
.
count
)
let
p
=
Float
(
i
)
/
Float
(
infos
.
count
-
1
)
let
fileURL
=
updateURL
.
appendingPathComponent
(
info
.
fileName
)
//Step 2
...
...
@@ -326,11 +333,13 @@ extension MRUpdateManager {
continue
}
//先创建必要的文件路径
self
.
createFolder
(
with
:
info
.
fileName
,
in
:
updateURL
)
//Step 3
let
fileURLInWWW
=
wwwURL
.
appendingPathComponent
(
info
.
fileName
)
if
fileURLInWWW
.
isURLExists
(),
self
.
isSameHash
(
with
:
fileURLInWWW
,
hash
:
info
.
fileHash
)
{
self
.
createFolder
(
with
:
info
.
fileName
,
in
:
updateURL
)
let
distURL
=
fileURL
.
deletingLastPathComponent
()
if
fileURLInWWW
.
syncCopy
(
to
:
distURL
)
==
nil
,
...
...
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