@@ -133,8 +133,9 @@ struct File {
133
133
compressionStream. addTask {
134
134
try Task . checkCancellation ( )
135
135
let position = _position
136
- let data = [ UInt8] ( unsafeUninitializedCapacity: blockSize + blockSize / 16 ) { buffer, count in
137
- data [ position..< min ( position + blockSize, data. endIndex) ] . withUnsafeBufferPointer { data in
136
+ let end = min ( position + blockSize, data. endIndex)
137
+ let data = [ UInt8] ( unsafeUninitializedCapacity: ( end - position) + ( end - position) / 16 ) { buffer, count in
138
+ data [ position..< end] . withUnsafeBufferPointer { data in
138
139
count = compression_encode_buffer ( buffer. baseAddress!, buffer. count, data. baseAddress!, data. count, nil , COMPRESSION_LZFSE)
139
140
guard count < buffer. count else {
140
141
count = 0
@@ -365,7 +366,7 @@ public struct Unxip {
365
366
366
367
// The assumption is that all directories are provided without trailing slashes
367
368
func parentDirectory< S: StringProtocol > ( of path: S ) -> S . SubSequence {
368
- return path [ ..< path. lastIndex ( of: " / " ) !]
369
+ path [ ..< path. lastIndex ( of: " / " ) !]
369
370
}
370
371
371
372
// https://bugs.swift.org/browse/SR-15816
@@ -384,9 +385,11 @@ public struct Unxip {
384
385
continue
385
386
}
386
387
387
- if let ( original, task) = hardlinks [ file. identifier] {
388
+ if let ( original, originalTask) = hardlinks [ file. identifier] {
389
+ let task = parentDirectoryTask ( for: file)
390
+ assert ( task != nil , file. name)
388
391
_ = taskStream. addRunningTask {
389
- await task. value
392
+ _ = await ( originalTask . value , task? . value)
390
393
warn ( link ( original, file. name) , " linking " )
391
394
}
392
395
continue
@@ -399,6 +402,7 @@ public struct Unxip {
399
402
let task = parentDirectoryTask ( for: file)
400
403
assert ( task != nil , file. name)
401
404
_ = taskStream. addRunningTask {
405
+ await task? . value
402
406
warn ( symlink ( String ( data: Data ( file. data. map ( Array . init) . reduce ( [ ] , + ) ) , encoding: . utf8) , file. name) , " symlinking " )
403
407
setStickyBit ( on: file)
404
408
}
0 commit comments