diff --git a/Meetingnotes.xcodeproj/project.pbxproj b/Meetingnotes.xcodeproj/project.pbxproj index 3041337..599e793 100644 --- a/Meetingnotes.xcodeproj/project.pbxproj +++ b/Meetingnotes.xcodeproj/project.pbxproj @@ -276,7 +276,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 41; + CURRENT_PROJECT_VERSION = 42; DEVELOPMENT_ASSET_PATHS = "\"meetingnotes/Preview Content\""; DEVELOPMENT_TEAM = G9LVHZAJNX; ENABLE_HARDENED_RUNTIME = YES; @@ -290,7 +290,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 15.0; - MARKETING_VERSION = 1.1.29; + MARKETING_VERSION = 1.1.30; ONLY_ACTIVE_ARCH = NO; OTHER_SWIFT_FLAGS = "$(inherited) -D ENABLE_TCC_SPI"; PRODUCT_BUNDLE_IDENTIFIER = net.jamesbone.meetingnotes; @@ -312,7 +312,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 41; + CURRENT_PROJECT_VERSION = 42; DEVELOPMENT_ASSET_PATHS = "\"meetingnotes/Preview Content\""; DEVELOPMENT_TEAM = G9LVHZAJNX; ENABLE_HARDENED_RUNTIME = YES; @@ -326,7 +326,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 15.0; - MARKETING_VERSION = 1.1.29; + MARKETING_VERSION = 1.1.30; ONLY_ACTIVE_ARCH = YES; OTHER_SWIFT_FLAGS = "$(inherited) -D ENABLE_TCC_SPI"; PRODUCT_BUNDLE_IDENTIFIER = net.jamesbone.meetingnotes; diff --git a/meetingnotes/Managers/LocalStorageManager.swift b/meetingnotes/Managers/LocalStorageManager.swift index 86bd587..5ff2e51 100644 --- a/meetingnotes/Managers/LocalStorageManager.swift +++ b/meetingnotes/Managers/LocalStorageManager.swift @@ -170,11 +170,13 @@ class LocalStorageManager { } } - for audioFile in recoveryAudioFiles(in: continuationFolder) { - let destination = previousFolder.appendingPathComponent(audioFile.url.lastPathComponent) + let recoveryFiles = recoveryAudioFiles(in: continuationFolder).map(\.url) + + recoveryDiagnosticFiles(in: continuationFolder) + for recoveryFile in recoveryFiles { + let destination = previousFolder.appendingPathComponent(recoveryFile.lastPathComponent) if FileManager.default.fileExists(atPath: destination.path) { guard FileManager.default.contentsEqual( - atPath: audioFile.url.path, + atPath: recoveryFile.path, andPath: destination.path ) else { rollbackMergedAudio(copiedAudioURLs, removeFolder: createdPreviousFolder ? previousFolder : nil) @@ -184,7 +186,7 @@ class LocalStorageManager { } do { - try FileManager.default.copyItem(at: audioFile.url, to: destination) + try FileManager.default.copyItem(at: recoveryFile, to: destination) copiedAudioURLs.append(destination) } catch { rollbackMergedAudio(copiedAudioURLs, removeFolder: createdPreviousFolder ? previousFolder : nil) @@ -206,6 +208,7 @@ class LocalStorageManager { merged.userNotes = mergedText(previous.userNotes, continuation.userNotes) merged.generatedNotes = mergedText(previous.generatedNotes, continuation.generatedNotes) merged.templateId = previous.templateId ?? continuation.templateId + merged.transcriptionError = previous.transcriptionError ?? continuation.transcriptionError if !recoveryAudioFiles(in: previousFolder).isEmpty { merged.recoveryAudioFolderName = previous.id.uuidString } @@ -347,6 +350,23 @@ class LocalStorageManager { } } + private func recoveryDiagnosticFiles(in folder: URL) -> [URL] { + guard let files = try? FileManager.default.contentsOfDirectory( + at: folder, + includingPropertiesForKeys: [.isRegularFileKey], + options: [.skipsHiddenFiles] + ) else { + return [] + } + + return files.filter { url in + let values = try? url.resourceValues(forKeys: [.isRegularFileKey]) + return values?.isRegularFile == true + && url.pathExtension.caseInsensitiveCompare("txt") == .orderedSame + && url.lastPathComponent.lowercased().hasPrefix("audio-diagnostics-") + } + } + func findRecoveryAudioFolder(for meeting: Meeting) -> URL? { let canonicalName = meeting.id.uuidString guard meeting.recoveryAudioFolderName == nil