File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
Tools/build-swiftly-release Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ let package = Package(
137137 . target( name: " LinuxPlatform " , condition: . when( platforms: [ . linux] ) ) ,
138138 . target( name: " MacOSPlatform " , condition: . when( platforms: [ . macOS] ) ) ,
139139 . product( name: " ArgumentParser " , package : " swift-argument-parser " ) ,
140+ . product( name: " _NIOFileSystem " , package : " swift-nio " ) ,
140141 ] ,
141142 path: " Tools/build-swiftly-release "
142143 ) ,
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import AsyncHTTPClient
33import Foundation
44import SwiftlyCore
55import SystemPackage
6+ import NIOFileSystem
67
78#if os(macOS)
89import MacOSPlatform
@@ -16,7 +17,7 @@ let currentPlatform = MacOS()
1617let currentPlatform = Linux ( )
1718#endif
1819
19- typealias fs = FileSystem
20+ typealias fs = SwiftlyCore . FileSystem
2021typealias sys = SystemCommand
2122
2223extension Runnable {
@@ -156,12 +157,14 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
156157 guard libarchiveResponse. status == . ok else {
157158 throw Error ( message: " Download failed with status: \( libarchiveResponse. status) " )
158159 }
159- let buf = try await libarchiveResponse. body. collect ( upTo: 20 * 1024 * 1024 )
160- guard let contents = buf. getBytes ( at: 0 , length: buf. readableBytes) else {
161- throw Error ( message: " Unable to read all of the bytes " )
160+
161+ try await NIOFileSystem . FileSystem. shared. withFileHandle ( forWritingAt: buildCheckoutsDir / " libarchive- \( libArchiveVersion) .tar.gz " , options: . newFile( replaceExisting: true ) ) { fileHandle in
162+ var pos : Int64 = 0
163+
164+ for try await buffer in libarchiveResponse. body {
165+ pos += try await fileHandle. write ( contentsOf: buffer, toAbsoluteOffset: pos)
166+ }
162167 }
163- let data = Data ( contents)
164- try data. write ( to: buildCheckoutsDir / " libarchive- \( libArchiveVersion) .tar.gz " )
165168
166169 let libArchiveTarShaActual = try await sys. sha256sum ( files: buildCheckoutsDir / " libarchive- \( libArchiveVersion) .tar.gz " ) . output ( currentPlatform)
167170 guard let libArchiveTarShaActual, libArchiveTarShaActual. starts ( with: libArchiveTarSha) else {
You can’t perform that action at this time.
0 commit comments