Skip to content

Commit

Permalink
fix: Show progress during command-line SIS installation (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbmorley authored Jul 24, 2024
1 parent 48fedf9 commit e85390e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions ReconnectCore/Sources/ReconnectCore/PLP/FileServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,13 @@ public class FileServer {
}

public func copyFileSync(fromLocalPath localSourcePath: String,
toRemotePath remoteDestinationPath: String) throws {
toRemotePath remoteDestinationPath: String,
callback: @escaping (UInt32, UInt32) -> ProgressResponse = { _, _ in return .continue }) throws {
dispatchPrecondition(condition: .notOnQueue(workQueue))
try workQueue.sync {
try self.syncQueue_copyFile(fromLocalPath: localSourcePath,
toRemotePath: remoteDestinationPath,
callback: { _, _ in return .continue })
callback: callback)
}
}

Expand Down
11 changes: 9 additions & 2 deletions ScreenshotSIS/Command.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ extension Installer: SisInstallIoHandler {
paths.append(.directory(destinationDirectory))
}
print("Writing file '\(op.path)'...")
try fileServer.copyFileSync(fromLocalPath: fullURL.path, toRemotePath: op.path)
try fileServer.copyFileSync(fromLocalPath: fullURL.path, toRemotePath: op.path) { progress, size in
let percentage = Float(progress) / Float(size)
print("\(percentage.formatted(.percent))")
return .continue
}
} catch {
print("Failed to write file '\(op.path)' with error '\(error)'.")
return .err(.notReady)
Expand Down Expand Up @@ -151,7 +155,10 @@ struct Command: AsyncParsableCommand {

// Copy the screenshot.
let outputURL = URL(filePath: outputDirectory).appendingPathComponent("screenshot.mbm")
try await fileServer.copyFile(fromRemotePath: "C:\\screenshot.mbm", toLocalPath: outputURL.path)
try await fileServer.copyFile(fromRemotePath: "C:\\screenshot.mbm", toLocalPath: outputURL.path) { progress, size in
print("\(progress) / \(size)")
return .continue
}
try await fileServer.remove(path: "C:\\screenshot.mbm")
try PsiLuaEnv().convertMultiBitmap(at: outputURL, removeSource: true)

Expand Down

0 comments on commit e85390e

Please sign in to comment.