Log accessed files
This commit is contained in:
parent
2e6542225f
commit
5b4db424b5
@ -27,6 +27,8 @@ final class FileAccess {
|
|||||||
|
|
||||||
private var changedFiles: Set<String> = []
|
private var changedFiles: Set<String> = []
|
||||||
|
|
||||||
|
private var accessedFiles: Set<String> = []
|
||||||
|
|
||||||
init(in root: URL, errorOutput: ErrorOutput) {
|
init(in root: URL, errorOutput: ErrorOutput) {
|
||||||
self.sourceFolder = root
|
self.sourceFolder = root
|
||||||
self.errorOutput = errorOutput
|
self.errorOutput = errorOutput
|
||||||
@ -63,6 +65,7 @@ final class FileAccess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func didAccess(inputPath: String, modified lastModified: Date, source: String) {
|
private func didAccess(inputPath: String, modified lastModified: Date, source: String) {
|
||||||
|
accessedFiles.insert(inputPath)
|
||||||
guard let previousDate = sourceLastModifiedTimes[inputPath] else {
|
guard let previousDate = sourceLastModifiedTimes[inputPath] else {
|
||||||
// File not processed before, so mark as changed
|
// File not processed before, so mark as changed
|
||||||
changedFiles.insert(inputPath)
|
changedFiles.insert(inputPath)
|
||||||
@ -143,4 +146,28 @@ final class FileAccess {
|
|||||||
print(" ...")
|
print(" ...")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func printAccessedFilesOverview() {
|
||||||
|
let count = accessedFiles.count
|
||||||
|
guard count > 0 else {
|
||||||
|
print("No files accessed")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
print("\(count) files accessed:")
|
||||||
|
accessedFiles.prefix(10).forEach { print(" " + $0) }
|
||||||
|
if count > 10 {
|
||||||
|
print(" ...")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func printAllTouchedFiles() {
|
||||||
|
print("\(accessedFiles.count) files accessed:")
|
||||||
|
accessedFiles.sorted().forEach { file in
|
||||||
|
if changedFiles.contains(file) {
|
||||||
|
print(" \(file) (changed)")
|
||||||
|
} else {
|
||||||
|
print(" " + file)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ do {
|
|||||||
}
|
}
|
||||||
|
|
||||||
siteData.printTree()
|
siteData.printTree()
|
||||||
context.fileSystem.printChangedFilesOverview()
|
context.fileSystem.printAllTouchedFiles()
|
||||||
context.fileSystem.didGenerateAllFiles()
|
context.fileSystem.didGenerateAllFiles()
|
||||||
|
|
||||||
exit(0)
|
exit(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user