diff --git a/Sources/Generator/Processing/FileGenerator.swift b/Sources/Generator/Processing/FileGenerator.swift index 66fbb9b..fba6c25 100644 --- a/Sources/Generator/Processing/FileGenerator.swift +++ b/Sources/Generator/Processing/FileGenerator.swift @@ -241,7 +241,9 @@ final class FileGenerator { func writeResults(to file: URL) { guard !unreadableFiles.isEmpty || !unwritableFiles.isEmpty || !failedMinifications.isEmpty || !missingFiles.isEmpty || !copiedFiles.isEmpty || !minifiedFiles.isEmpty || !files.expected.isEmpty || !files.external.isEmpty else { do { - try FileManager.default.removeItem(at: file) + if FileManager.default.fileExists(atPath: file.path) { + try FileManager.default.removeItem(at: file) + } } catch { print(" Failed to delete file log: \(error)") } diff --git a/Sources/Generator/Processing/GenerationResultsHandler.swift b/Sources/Generator/Processing/GenerationResultsHandler.swift index 912601e..443a31e 100644 --- a/Sources/Generator/Processing/GenerationResultsHandler.swift +++ b/Sources/Generator/Processing/GenerationResultsHandler.swift @@ -457,7 +457,9 @@ final class GenerationResultsHandler { func writeResults(to file: URL) { guard !missingFiles.isEmpty || !unreadableFiles.isEmpty || !unwritableFiles.isEmpty || !missingLinkedPages.isEmpty || !pageWarnings.isEmpty || !generatedFiles.isEmpty || !draftPages.isEmpty || !emptyPages.isEmpty else { do { - try FileManager.default.removeItem(at: file) + if FileManager.default.fileExists(atPath: file.path) { + try FileManager.default.removeItem(at: file) + } } catch { print(" Failed to delete generation log: \(error)") } diff --git a/Sources/Generator/Processing/ImageGenerator.swift b/Sources/Generator/Processing/ImageGenerator.swift index 117ed9d..96566a8 100644 --- a/Sources/Generator/Processing/ImageGenerator.swift +++ b/Sources/Generator/Processing/ImageGenerator.swift @@ -314,7 +314,9 @@ final class ImageGenerator { func writeResults(to file: URL) { guard !missingImages.isEmpty || !unreadableImages.isEmpty || !failedImages.isEmpty || !unhandledImages.isEmpty || !imageWarnings.isEmpty || !generatedImages.isEmpty || !optimizedImages.isEmpty else { do { - try FileManager.default.removeItem(at: file) + if FileManager.default.fileExists(atPath: file.path) { + try FileManager.default.removeItem(at: file) + } } catch { print(" Failed to delete image log: \(error)") } diff --git a/Sources/Generator/Processing/MetadataInfoLogger.swift b/Sources/Generator/Processing/MetadataInfoLogger.swift index bca5c08..4a3aebc 100644 --- a/Sources/Generator/Processing/MetadataInfoLogger.swift +++ b/Sources/Generator/Processing/MetadataInfoLogger.swift @@ -153,7 +153,9 @@ final class MetadataInfoLogger { func writeResults(to file: URL) { guard !errors.isEmpty || !warnings.isEmpty || !unreadableMetadata.isEmpty || !unusedProperties.isEmpty || !invalidProperties.isEmpty || !unknownProperties.isEmpty || !missingProperties.isEmpty else { do { - try FileManager.default.removeItem(at: file) + if FileManager.default.fileExists(atPath: file.path) { + try FileManager.default.removeItem(at: file) + } } catch { print(" Failed to delete metadata log: \(error)") }