Actually write files log

This commit is contained in:
Christoph Hagen 2023-01-08 21:49:01 +01:00
parent 10267e3765
commit e5804ac0c7
2 changed files with 2 additions and 20 deletions

View File

@ -61,26 +61,6 @@ final class FileGenerator {
print("")
}
func writeResultsToFile(file: URL) throws {
var lines: [String] = []
func add<S>(_ name: String, _ property: S, convert: (S.Element) -> String) where S: Sequence {
let elements = property.map { " " + convert($0) }.sorted()
guard !elements.isEmpty else {
return
}
lines.append("\(name):")
lines.append(contentsOf: elements)
}
add("Missing files", missingFiles) { "\($0.key) (required by \($0.value))" }
add("Unreadable files", unreadableFiles) { "\($0.key) (required by \($0.value.source)): \($0.value.message)" }
add("Unreadable files", unreadableFiles) { "\($0.key) (required by \($0.value.source)): \($0.value.message)" }
add("Unwritable files", unwritableFiles) { "\($0.key) (required by \($0.value.source)): \($0.value.message)" }
add("External files", files.external) { "\($0.key) (from \($0.value))" }
let data = lines.joined(separator: "\n").data(using: .utf8)!
try data.createFolderAndWrite(to: file)
}
private func didCopyFile() {
numberOfCopiedFiles += 1
print(" Copied files: \(numberOfCopiedFiles)/\(numberOfFilesToCopy) \r", terminator: "")

View File

@ -113,6 +113,8 @@ private func copyFiles(files: FileData, configuration: Configuration, runFolder:
runFolder: runFolder,
files: files)
generator.generate()
let file = runFolder.appendingPathComponent("files.txt")
generator.writeResults(to: file)
}
private func finish(start: Date, complete: Bool) {