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

FIX: swift-doc creates file and directory with unexpected permission #146

Merged
merged 2 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/swift-doc/Subcommands/Generate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extension SwiftDoc {
let baseURL = options.baseURL

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

do {
let format = options.format
Expand Down
6 changes: 1 addition & 5 deletions Sources/swift-doc/Supporting Types/Page.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,8 @@ extension Page {
}
}



func writeFile(_ data: Data, to url: URL) throws {
let fileManager = FileManager.default
try fileManager.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true, attributes: [.posixPermissions: 0o744])

try fileManager.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)
try data.write(to: url)
try fileManager.setAttributes([.posixPermissions: 0o744], ofItemAtPath: url.path)
}
1 change: 0 additions & 1 deletion Sources/swift-doc/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ LoggingSystem.bootstrap { label in
let logger = Logger(label: "org.swiftdoc.swift-doc")

let fileManager = FileManager.default
let fileAttributes: [FileAttributeKey : Any] = [.posixPermissions: 0o744]

var standardOutput = FileHandle.standardOutput
var standardError = FileHandle.standardError
Expand Down
2 changes: 1 addition & 1 deletion Tests/SwiftDocTests/Helpers/temporaryFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation

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

let path = path ?? ProcessInfo.processInfo.globallyUniqueString
let temporaryFileURL = temporaryDirectoryURL.appendingPathComponent(path)
Expand Down