@@ -29,22 +29,33 @@ extension UIMode {
2929
3030class UI : StoreSubscriber {
3131 static var domain = Constants . UI_ENDPOINT_URL. host!
32- static func unarchiveLocal ( ) {
32+
33+ static func unarchiveZip ( ) {
3334 // Unpack Archive
3435 let file = FileManager . default
35-
36- if !file. fileExists ( atPath: appSupportUIZipPath. path) {
37- Console . log ( " \( appSupportUIZipPath. path) doesnt exist " )
38- let bundleUIZipPath = Bundle . main. url ( forResource: " ui " , withExtension: " zip " ) !
39- try ! file. copyItem ( at: bundleUIZipPath, to: appSupportUIZipPath)
40- }
4136
42- try ! Zip . unzipFile ( appSupportUIZipPath, destination: localPath, overwrite: true , password: nil ) // Unzip
37+ if file. fileExists ( atPath: remoteZipPath. path) {
38+ try ! Zip . unzipFile ( remoteZipPath, destination: localPath, overwrite: true , password: nil ) // Unzip
39+ } else {
40+ if !file. fileExists ( atPath: localZipPath. path) {
41+ Console . log ( " \( localZipPath. path) doesnt exist " )
42+ let bundleUIZipPath = Bundle . main. url ( forResource: " ui " , withExtension: " zip " ) !
43+ try ! file. copyItem ( at: bundleUIZipPath, to: localZipPath)
44+ }
45+ try ! Zip . unzipFile ( localZipPath, destination: localPath, overwrite: true , password: nil ) // Unzip
46+ }
47+ }
48+
49+ static var localZipPath : URL {
50+ return Application . supportPath. appendingPathComponent (
51+ " ui- \( Application . version) (Local).zip " ,
52+ isDirectory: false
53+ )
4354 }
4455
45- static var appSupportUIZipPath : URL {
56+ static var remoteZipPath : URL {
4657 return Application . supportPath. appendingPathComponent (
47- " ui- \( Application . version) .zip " ,
58+ " ui- \( Application . version) (Remote) .zip" ,
4859 isDirectory: false
4960 )
5061 }
@@ -247,7 +258,7 @@ class UI: StoreSubscriber {
247258 self . cacheRemote ( )
248259 } else {
249260 Console . log ( " Loading Local UI " )
250- UI . unarchiveLocal ( )
261+ UI . unarchiveZip ( )
251262 let url = URL ( string: " \( UI . localPath) /index.html " ) !
252263 UI . viewController. load ( url)
253264 }
@@ -259,7 +270,7 @@ class UI: StoreSubscriber {
259270 // Only download ui.zip when UI endpoint is remote
260271 if Constants . UI_ENDPOINT_URL. absoluteString. contains ( Constants . DOMAIN) {
261272 let destination : DownloadRequest . Destination = { _, _ in
262- return ( UI . appSupportUIZipPath , [ . removePreviousFile, . createIntermediateDirectories] )
273+ return ( UI . remoteZipPath , [ . removePreviousFile, . createIntermediateDirectories] )
263274 }
264275 AF . download ( " \( Constants . UI_ENDPOINT_URL) /ui.zip " , to: destination) . response { resp in
265276 if resp. error == nil {
0 commit comments