Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 2f79e97

Browse files
authored
FIX: swift-doc creates file and directory with unexpected permission (#146)
* FIX: swift-doc creates file and directory with unexpected permission **Problem** swift-doc creates file with execution bit, also creates directory without execution bit. **Solution** Remove unexpected permission attributes given to the `FileManager` and let them to use file system defaults. * Update changelog.
1 parent 2ef54e2 commit 2f79e97

File tree

5 files changed

+5
-8
lines changed

5 files changed

+5
-8
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3131
#131 by @MattKiazyk.
3232
- Fixed display of bullet list items in documentation discussion parts.
3333
#130 by @mattt.
34+
- Fixed file and directory unexpected permissions.
35+
#146 by @niw.
3436

3537
## [1.0.0-beta.3] - 2020-05-19
3638

Sources/swift-doc/Subcommands/Generate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ extension SwiftDoc {
5050
let baseURL = options.baseURL
5151

5252
let outputDirectoryURL = URL(fileURLWithPath: options.output)
53-
try fileManager.createDirectory(at: outputDirectoryURL, withIntermediateDirectories: true, attributes: fileAttributes)
53+
try fileManager.createDirectory(at: outputDirectoryURL, withIntermediateDirectories: true)
5454

5555
do {
5656
let format = options.format

Sources/swift-doc/Supporting Types/Page.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,8 @@ extension Page {
3535
}
3636
}
3737

38-
39-
4038
func writeFile(_ data: Data, to url: URL) throws {
4139
let fileManager = FileManager.default
42-
try fileManager.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true, attributes: [.posixPermissions: 0o744])
43-
40+
try fileManager.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)
4441
try data.write(to: url)
45-
try fileManager.setAttributes([.posixPermissions: 0o744], ofItemAtPath: url.path)
4642
}

Sources/swift-doc/main.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ LoggingSystem.bootstrap { label in
1414
let logger = Logger(label: "org.swiftdoc.swift-doc")
1515

1616
let fileManager = FileManager.default
17-
let fileAttributes: [FileAttributeKey : Any] = [.posixPermissions: 0o744]
1817

1918
var standardOutput = FileHandle.standardOutput
2019
var standardError = FileHandle.standardError

Tests/SwiftDocTests/Helpers/temporaryFile.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22

33
func temporaryFile(path: String? = nil, contents: String) throws -> URL {
44
let temporaryDirectoryURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(ProcessInfo.processInfo.globallyUniqueString)
5-
try FileManager.default.createDirectory(at: temporaryDirectoryURL, withIntermediateDirectories: true, attributes: [.posixPermissions: 0o766])
5+
try FileManager.default.createDirectory(at: temporaryDirectoryURL, withIntermediateDirectories: true)
66

77
let path = path ?? ProcessInfo.processInfo.globallyUniqueString
88
let temporaryFileURL = temporaryDirectoryURL.appendingPathComponent(path)

0 commit comments

Comments
 (0)