Skip to content

Commit

Permalink
Merge branch 'bigsur'
Browse files Browse the repository at this point in the history
  • Loading branch information
zqqf16 committed Nov 24, 2020
2 parents c40bfbd + 6034c99 commit 4389491
Show file tree
Hide file tree
Showing 56 changed files with 1,373 additions and 909 deletions.
62 changes: 43 additions & 19 deletions SYM.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file modified SYM/Assets.xcassets/AppIcon.appiconset/icon_128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SYM/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SYM/Assets.xcassets/AppIcon.appiconset/icon_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SYM/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SYM/Assets.xcassets/AppIcon.appiconset/icon_256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SYM/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SYM/Assets.xcassets/AppIcon.appiconset/icon_32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SYM/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SYM/Assets.xcassets/AppIcon.appiconset/icon_512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SYM/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 0 additions & 15 deletions SYM/Assets.xcassets/Cloud.imageset/Contents.json

This file was deleted.

Binary file removed SYM/Assets.xcassets/Cloud.imageset/cloud.pdf
Binary file not shown.
6 changes: 3 additions & 3 deletions SYM/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
15 changes: 0 additions & 15 deletions SYM/Assets.xcassets/Device.imageset/Contents.json

This file was deleted.

Binary file removed SYM/Assets.xcassets/Device.imageset/iphone.pdf
Binary file not shown.
15 changes: 0 additions & 15 deletions SYM/Assets.xcassets/Play.imageset/Contents.json

This file was deleted.

Binary file removed SYM/Assets.xcassets/Play.imageset/play.pdf
Binary file not shown.
15 changes: 0 additions & 15 deletions SYM/Assets.xcassets/Reticle.imageset/Contents.json

This file was deleted.

Binary file removed SYM/Assets.xcassets/Reticle.imageset/reticle.pdf
Binary file not shown.
82 changes: 0 additions & 82 deletions SYM/DeviceBaseViewController.swift

This file was deleted.

134 changes: 53 additions & 81 deletions SYM/Dsym/DsymDownloader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,72 +20,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

import Foundation
import Cocoa

struct DsymDownloadStatusEvent: Event {
let task: DsymDownloadTask
let status: DsymDownloadTask.Status
}

struct DsymDownloadProgressEvent: Event {
let task: DsymDownloadTask
let progress: DsymDownloadProgress
}

class DsymDownloadProgress: CustomStringConvertible {
var percentage: Int = 0
var totalSize: String = "0"
var downloadedSize: String = "0"
var timeLeft: String = "Unknow"
var speed: String = "0"

var description: String {
return "\(percentage)% \(downloadedSize)/\(totalSize) \(timeLeft) \(speed)/s"
}

func update(fromConsoleOutput output: String) {
/*
curl
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
10 286M 10 30.2M 0 0 830k 0 0:05:53 0:00:37 0:05:16 1660k
*/
let title = "% Total % Received % Xferd Average Speed Time Time Time Current"
guard let range = output.range(of: title) else {
return
}

let content = output[range.upperBound...]
let lines = content.components(separatedBy: "\r")
let count = lines.count
if count < 3 {
return;
}

var items: [String] = []
for index in (count-2..<count).reversed() {
let lastLine = lines[index]
items = lastLine.components(separatedBy: " ").filter({ (string) -> Bool in
string != ""
})
if items.count >= 12 {
break
}
}

if items.count != 12 || !items[10].contains(":") {
return
}

self.percentage = Int(items[0]) ?? 0
self.totalSize = items[1]
self.downloadedSize = items[3]
self.timeLeft = items[10]
self.speed = items[11]
//print(self)
}
}
import Combine

class DsymDownloadTask {
var crashInfo: CrashInfo
Expand All @@ -106,20 +42,62 @@ class DsymDownloadTask {
}
}
}

fileprivate var eventBus: EventBus?

var status: Status = .waiting {
didSet {
if let eb = self.eventBus {
eb.post(DsymDownloadStatusEvent(task: self, status: self.status))
struct Progress {
var percentage: Int = 0
var totalSize: String = "0"
var downloadedSize: String = "0"
var timeLeft: String = "Unknow"
var speed: String = "0"

mutating func update(fromConsoleOutput output: String) {
/*
curl
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
10 286M 10 30.2M 0 0 830k 0 0:05:53 0:00:37 0:05:16 1660k
*/
let title = "% Total % Received % Xferd Average Speed Time Time Time Current"
guard let range = output.range(of: title) else {
return
}

let content = output[range.upperBound...]
let lines = content.components(separatedBy: "\r")
let count = lines.count
if count < 3 {
return;
}

var items: [String] = []
for index in (count-2..<count).reversed() {
let lastLine = lines[index]
items = lastLine.components(separatedBy: " ").filter({ (string) -> Bool in
string != ""
})
if items.count >= 12 {
break
}
}

if items.count != 12 || !items[10].contains(":") {
return
}

self.percentage = Int(items[0]) ?? 0
self.totalSize = items[1]
self.downloadedSize = items[3]
self.timeLeft = items[10]
self.speed = items[11]
//print(self)
}
}

@Published var status: Status = .waiting
@Published var progress: Progress = Progress()

var statusCode: Int = 0
var message: String?
var progress: DsymDownloadProgress = DsymDownloadProgress()
var dsymFiles: [DsymFile]?

private var process: SubProcess!
Expand Down Expand Up @@ -157,9 +135,6 @@ class DsymDownloadTask {
self.process.errorHandler = { [weak self] (_) in
if let this = self {
this.progress.update(fromConsoleOutput: this.process.error)
if let eventBus = this.eventBus {
eventBus.post(DsymDownloadProgressEvent(task: this, progress: this.progress))
}
}
}
self.status = .running
Expand All @@ -177,7 +152,7 @@ class DsymDownloadTask {
}

func cancel() {
self.process.terminate()
self.process?.terminate()
self.status = .canceled
}

Expand Down Expand Up @@ -227,8 +202,7 @@ class DsymDownloadTask {
class DsymDownloader {
static let shared = DsymDownloader()

let eventBus = EventBus()
var tasks:[String: DsymDownloadTask] = [:]
@Published var tasks:[String: DsymDownloadTask] = [:]

private let scriptURL = Config.downloadScriptURL()

Expand Down Expand Up @@ -258,13 +232,11 @@ class DsymDownloader {
}

let task = DsymDownloadTask(crashInfo: crashInfo, scriptURL: self.scriptURL, fileURL: fileURL)
task.eventBus = self.eventBus
self.tasks[uuid] = task
DispatchQueue.global().async {
task.run()
}

self.eventBus.post(DsymDownloadStatusEvent(task: task, status: task.status))

return task
}
}
17 changes: 10 additions & 7 deletions SYM/Dsym/DsymManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// SOFTWARE.

import Foundation
import Combine

extension Notification.Name {
static let dsymDidUpdate = Notification.Name("sym.dsymDidUpdate")
Expand Down Expand Up @@ -68,18 +69,20 @@ class DsymManager {
}()

private var uuids: [String]?
private var storage = Set<AnyCancellable>()

init() {
self.monitor.delegate = self
DsymDownloader.shared.eventBus.sub(self, for: DsymDownloadStatusEvent.self).async { (event) in
guard event.task.crashInfo.uuid == self.crash.uuid,
self.dsymFiles.count == 0,
let dsymFiles = event.task.dsymFiles else {
return
DsymDownloader.shared.$tasks.sink { [weak self] (tasks) in
guard let uuid = self?.crash?.uuid,
let task = tasks[uuid],
let files = task.dsymFiles
else {
return
}

self.dsymFileDidUpdate(dsymFiles)
}
self?.dsymFileDidUpdate(files)
}.store(in: &storage)
}

func update(_ crash: CrashInfo) {
Expand Down
Loading

0 comments on commit 4389491

Please sign in to comment.