Skip to content

Commit d2eb350

Browse files
authored
Preserve permissions by default and fix warnings (apple#496)
Permissions should be preserved when copying by default. This PR also fixes other warnings while building and testing.
1 parent b9a6bf5 commit d2eb350

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

Sources/NativeBuilder/ContainerBuildIR/Graph/GraphBuilder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public final class GraphBuilder {
219219
destination: destination,
220220
fileMetadata: FileMetadata(
221221
ownership: chown,
222-
permissions: chmod
222+
permissions: chmod ?? .preserve
223223
)
224224
)
225225

Tests/NativeBuilderTests/ContainerBuildIRTests/DigestAndPlatformTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ struct DigestAndPlatformTests {
263263

264264
@Test func digestErrorMessages() throws {
265265
do {
266-
try Digest(algorithm: .sha256, bytes: Data(count: 16))
266+
_ = try Digest(algorithm: .sha256, bytes: Data(count: 16))
267267
Issue.record("Should have thrown an error")
268268
} catch let error as DigestError {
269269
switch error {
@@ -278,7 +278,7 @@ struct DigestAndPlatformTests {
278278
}
279279

280280
do {
281-
try Digest(parsing: "invalid:format")
281+
_ = try Digest(parsing: "invalid:format")
282282
Issue.record("Should have thrown an error")
283283
} catch let error as DigestError {
284284
switch error {
@@ -291,7 +291,7 @@ struct DigestAndPlatformTests {
291291
}
292292

293293
do {
294-
try Digest(parsing: "sha256:invalid-hex")
294+
_ = try Digest(parsing: "sha256:invalid-hex")
295295
Issue.record("Should have thrown an error")
296296
} catch let error as DigestError {
297297
switch error {

Tests/NativeBuilderTests/ContainerBuildIRTests/SerializationTests.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,10 @@ struct SerializationTests {
267267

268268
// Check for COPY operation with metadata
269269
let copyOps = stage.nodes.compactMap { $0.operation as? FilesystemOperation }
270-
let copyWithMetadata = copyOps.first { $0.fileMetadata != nil }
271-
#expect(copyWithMetadata != nil, "COPY operation with metadata should be preserved")
270+
let copyWithMetadata = copyOps.first {
271+
$0.fileMetadata.permissions != nil
272+
}
273+
#expect(copyWithMetadata != nil, "COPY operation should preserve file permissions by default")
272274

273275
// Check for metadata operations
274276
let metaOps = stage.nodes.compactMap { $0.operation as? MetadataOperation }

0 commit comments

Comments
 (0)