Check if log file exists

This commit is contained in:
Christoph Hagen 2023-01-08 21:50:28 +01:00
parent e5804ac0c7
commit a05ed4dfcd
4 changed files with 12 additions and 4 deletions

View File

@ -241,7 +241,9 @@ final class FileGenerator {
func writeResults(to file: URL) { 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 { guard !unreadableFiles.isEmpty || !unwritableFiles.isEmpty || !failedMinifications.isEmpty || !missingFiles.isEmpty || !copiedFiles.isEmpty || !minifiedFiles.isEmpty || !files.expected.isEmpty || !files.external.isEmpty else {
do { do {
if FileManager.default.fileExists(atPath: file.path) {
try FileManager.default.removeItem(at: file) try FileManager.default.removeItem(at: file)
}
} catch { } catch {
print(" Failed to delete file log: \(error)") print(" Failed to delete file log: \(error)")
} }

View File

@ -457,7 +457,9 @@ final class GenerationResultsHandler {
func writeResults(to file: URL) { func writeResults(to file: URL) {
guard !missingFiles.isEmpty || !unreadableFiles.isEmpty || !unwritableFiles.isEmpty || !missingLinkedPages.isEmpty || !pageWarnings.isEmpty || !generatedFiles.isEmpty || !draftPages.isEmpty || !emptyPages.isEmpty else { guard !missingFiles.isEmpty || !unreadableFiles.isEmpty || !unwritableFiles.isEmpty || !missingLinkedPages.isEmpty || !pageWarnings.isEmpty || !generatedFiles.isEmpty || !draftPages.isEmpty || !emptyPages.isEmpty else {
do { do {
if FileManager.default.fileExists(atPath: file.path) {
try FileManager.default.removeItem(at: file) try FileManager.default.removeItem(at: file)
}
} catch { } catch {
print(" Failed to delete generation log: \(error)") print(" Failed to delete generation log: \(error)")
} }

View File

@ -314,7 +314,9 @@ final class ImageGenerator {
func writeResults(to file: URL) { func writeResults(to file: URL) {
guard !missingImages.isEmpty || !unreadableImages.isEmpty || !failedImages.isEmpty || !unhandledImages.isEmpty || !imageWarnings.isEmpty || !generatedImages.isEmpty || !optimizedImages.isEmpty else { guard !missingImages.isEmpty || !unreadableImages.isEmpty || !failedImages.isEmpty || !unhandledImages.isEmpty || !imageWarnings.isEmpty || !generatedImages.isEmpty || !optimizedImages.isEmpty else {
do { do {
if FileManager.default.fileExists(atPath: file.path) {
try FileManager.default.removeItem(at: file) try FileManager.default.removeItem(at: file)
}
} catch { } catch {
print(" Failed to delete image log: \(error)") print(" Failed to delete image log: \(error)")
} }

View File

@ -153,7 +153,9 @@ final class MetadataInfoLogger {
func writeResults(to file: URL) { func writeResults(to file: URL) {
guard !errors.isEmpty || !warnings.isEmpty || !unreadableMetadata.isEmpty || !unusedProperties.isEmpty || !invalidProperties.isEmpty || !unknownProperties.isEmpty || !missingProperties.isEmpty else { guard !errors.isEmpty || !warnings.isEmpty || !unreadableMetadata.isEmpty || !unusedProperties.isEmpty || !invalidProperties.isEmpty || !unknownProperties.isEmpty || !missingProperties.isEmpty else {
do { do {
if FileManager.default.fileExists(atPath: file.path) {
try FileManager.default.removeItem(at: file) try FileManager.default.removeItem(at: file)
}
} catch { } catch {
print(" Failed to delete metadata log: \(error)") print(" Failed to delete metadata log: \(error)")
} }