File tree Expand file tree Collapse file tree 1 file changed +23
-3
lines changed
Sources/BinaryDependencyManager Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -208,15 +208,35 @@ struct DependenciesResolverRunner {
208208 }
209209
210210 private func calculateChecksum( path: String ) throws -> String {
211- let handle = try FileHandle ( forReadingFrom: URL ( fileURLWithPath: path) )
212- var hasher = SHA256 ( )
211+ // Read the file in chunks to avoid RAM issues
212+
213+ let handle : FileHandle = try FileHandle ( forReadingFrom: URL ( fileURLWithPath: path) )
214+ var hasher : SHA256 = SHA256 ( )
215+
216+ #if os(macOS)
217+
213218 while autoreleasepool ( invoking: {
214219 let nextChunk = handle. readData ( ofLength: 1024 * 1024 )
215220 guard !nextChunk. isEmpty else { return false }
216221 hasher. update ( data: nextChunk)
217222 return true
218223 } ) { }
219- let digest = hasher. finalize ( )
224+
225+ #elseif os(Linux)
226+
227+ var eof : Bool = false
228+ var nextChunk : Data
229+
230+ while !eof {
231+ nextChunk = handle. readData ( ofLength: 1024 * 1024 )
232+ eof = nextChunk. isEmpty
233+ if !eof {
234+ hasher. update ( data: nextChunk)
235+ }
236+ }
237+
238+ #endif
239+ let digest : SHA256 . Digest = hasher. finalize ( )
220240 return digest. map { String ( format: " %02hhx " , $0) } . joined ( )
221241 }
222242}
You can’t perform that action at this time.
0 commit comments