@@ -165,12 +165,12 @@ extension Workspace {
165
165
166
166
// finally download zip files, if any
167
167
for artifact in zipArtifacts. get ( ) {
168
- let parentDirectory = artifactsDirectory. appending ( component: artifact. packageRef. identity. description)
169
- guard observabilityScope. trap ( { try fileSystem. createDirectory ( parentDirectory , recursive: true ) } ) else {
168
+ let destinationDirectory = artifactsDirectory. appending ( component: artifact. packageRef. identity. description)
169
+ guard observabilityScope. trap ( { try fileSystem. createDirectory ( destinationDirectory , recursive: true ) } ) else {
170
170
continue
171
171
}
172
172
173
- let archivePath = parentDirectory . appending ( component: artifact. url. lastPathComponent)
173
+ let archivePath = destinationDirectory . appending ( component: artifact. url. lastPathComponent)
174
174
if self . fileSystem. exists ( archivePath) {
175
175
guard observabilityScope. trap ( { try self . fileSystem. removeFileTree ( archivePath) } ) else {
176
176
continue
@@ -241,7 +241,7 @@ extension Workspace {
241
241
case . success:
242
242
var artifactPath : AbsolutePath ? = nil
243
243
observabilityScope. trap {
244
- try self . fileSystem. withLock ( on: parentDirectory , type: . exclusive) {
244
+ try self . fileSystem. withLock ( on: destinationDirectory , type: . exclusive) {
245
245
// strip first level component if needed
246
246
if try self . fileSystem. shouldStripFirstLevel ( archiveDirectory: tempExtractionDirectory, acceptableExtensions: BinaryTarget . Kind. allCases. map ( { $0. fileExtension } ) ) {
247
247
observabilityScope. emit ( debug: " stripping first level component from \( tempExtractionDirectory) " )
@@ -253,7 +253,7 @@ extension Workspace {
253
253
// copy from temp location to actual location
254
254
for file in content {
255
255
let source = tempExtractionDirectory. appending ( component: file)
256
- let destination = parentDirectory . appending ( component: file)
256
+ let destination = destinationDirectory . appending ( component: file)
257
257
if self . fileSystem. exists ( destination) {
258
258
try self . fileSystem. removeFileTree ( destination)
259
259
}
@@ -332,24 +332,26 @@ extension Workspace {
332
332
case . success:
333
333
observabilityScope. trap { ( ) -> Void in
334
334
var artifactPath : AbsolutePath ? = nil
335
- // strip first level component if needed
336
- if try self . fileSystem. shouldStripFirstLevel ( archiveDirectory: tempExtractionDirectory, acceptableExtensions: BinaryTarget . Kind. allCases. map ( { $0. fileExtension } ) ) {
337
- observabilityScope. emit ( debug: " stripping first level component from \( tempExtractionDirectory) " )
338
- try self . fileSystem. stripFirstLevel ( of: tempExtractionDirectory)
339
- } else {
340
- observabilityScope. emit ( debug: " no first level component stripping needed for \( tempExtractionDirectory) " )
341
- }
342
- let content = try self . fileSystem. getDirectoryContents ( tempExtractionDirectory)
343
- // copy from temp location to actual location
344
- for file in content {
345
- let source = tempExtractionDirectory. appending ( component: file)
346
- let destination = destinationDirectory. appending ( component: file)
347
- if self . fileSystem. exists ( destination) {
348
- try self . fileSystem. removeFileTree ( destination)
335
+ try self . fileSystem. withLock ( on: destinationDirectory, type: . exclusive) {
336
+ // strip first level component if needed
337
+ if try self . fileSystem. shouldStripFirstLevel ( archiveDirectory: tempExtractionDirectory, acceptableExtensions: BinaryTarget . Kind. allCases. map ( { $0. fileExtension } ) ) {
338
+ observabilityScope. emit ( debug: " stripping first level component from \( tempExtractionDirectory) " )
339
+ try self . fileSystem. stripFirstLevel ( of: tempExtractionDirectory)
340
+ } else {
341
+ observabilityScope. emit ( debug: " no first level component stripping needed for \( tempExtractionDirectory) " )
349
342
}
350
- try self . fileSystem. copy ( from: source, to: destination)
351
- if artifact. isMatchingDirectory ( destination) {
352
- artifactPath = destination
343
+ let content = try self . fileSystem. getDirectoryContents ( tempExtractionDirectory)
344
+ // copy from temp location to actual location
345
+ for file in content {
346
+ let source = tempExtractionDirectory. appending ( component: file)
347
+ let destination = destinationDirectory. appending ( component: file)
348
+ if self . fileSystem. exists ( destination) {
349
+ try self . fileSystem. removeFileTree ( destination)
350
+ }
351
+ try self . fileSystem. copy ( from: source, to: destination)
352
+ if artifact. isMatchingDirectory ( destination) {
353
+ artifactPath = destination
354
+ }
353
355
}
354
356
}
355
357
0 commit comments