diff --git a/WebsiteGenerator/Content/Element.swift b/WebsiteGenerator/Content/Element.swift index e7b93e8..d91ceac 100644 --- a/WebsiteGenerator/Content/Element.swift +++ b/WebsiteGenerator/Content/Element.swift @@ -473,7 +473,7 @@ extension Element { */ private func existingContentUrl(for language: String) -> URL? { let url = contentUrl(for: language) - guard url.exists else { + guard url.exists, let size = url.size, size > 0 else { return nil } return url diff --git a/WebsiteGenerator/Extensions/URL+Extensions.swift b/WebsiteGenerator/Extensions/URL+Extensions.swift index 9422312..f88a55f 100644 --- a/WebsiteGenerator/Extensions/URL+Extensions.swift +++ b/WebsiteGenerator/Extensions/URL+Extensions.swift @@ -35,4 +35,9 @@ extension URL { try url.ensureParentFolderExistence() try FileManager.default.copyItem(at: self, to: url) } + + var size: Int? { + let attributes = try? FileManager.default.attributesOfItem(atPath: path) + return (attributes?[.size] as? NSNumber)?.intValue + } }