Skip to content

Commit

Permalink
Add utility function for updating progress
Browse files Browse the repository at this point in the history
  • Loading branch information
fwcd committed Apr 29, 2024
1 parent c822d67 commit fda53e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/MusicLibrary/Process/CopyProcessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public struct CopyProcessor: LibraryProcessor {
let oldURL = track.url
let newURL = mapping(track)

var newProgress = progress
newProgress.current = i
newProgress.message = "Copying to \(newURL)..."
progress = newProgress
progress.update(
current: i,
message: "Copying to \(newURL)..."
)

if let oldURL {
try FileManager.default.copyItem(at: oldURL, to: newURL)
Expand Down
6 changes: 6 additions & 0 deletions Sources/MusicLibrary/Utils/ProgressInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ public struct ProgressInfo {
public var current: Int
public var total: Int
public var message: String? = nil

public mutating func update(current: Int? = nil, total: Int? = nil, message: String? = nil) {
self.current = current ?? self.current
self.total = total ?? self.total
self.message = message ?? self.message
}
}

0 comments on commit fda53e8

Please sign in to comment.