fix(IOS-INFO-043): set vm.filePath after COS download + cleanup
- MaterialReaderViewModel.filePath: let → var for runtime updates - Set vm.filePath to downloaded temp path before vm.load() - Remove unused downloadedFilePath/resolvedPath Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
915d5e3fe2
commit
4059f0197e
Binary file not shown.
@ -24,7 +24,7 @@ final class MaterialReaderViewModel: ObservableObject {
|
||||
@Published var stats: TextStats?
|
||||
|
||||
let materialId: String
|
||||
let filePath: String
|
||||
var filePath: String
|
||||
let materialType: MaterialType
|
||||
let mode: PreviewMode
|
||||
|
||||
@ -109,19 +109,9 @@ struct MaterialReaderView: View {
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
@State private var isParsing = false
|
||||
@State private var parseMessage = ""
|
||||
@State private var downloadedFilePath: String?
|
||||
|
||||
private let title: String
|
||||
private let knowledgeBaseId: String?
|
||||
|
||||
/// Resolved file path: uses downloaded temp file if original is empty/missing
|
||||
private var resolvedPath: String {
|
||||
if !vm.filePath.isEmpty && FileManager.default.fileExists(atPath: vm.filePath) {
|
||||
return vm.filePath
|
||||
}
|
||||
return downloadedFilePath ?? vm.filePath
|
||||
}
|
||||
|
||||
// V2 session manager (primary) + V1 collector (fallback)
|
||||
private let sessionManager = ReadingRuntimeSessionManager.shared
|
||||
private let collector = ReadingEventCollector.shared
|
||||
@ -262,8 +252,8 @@ struct MaterialReaderView: View {
|
||||
let localURL = FileManager.default.temporaryDirectory
|
||||
.appendingPathComponent("source_\(vm.materialId).\(ext)")
|
||||
try data.write(to: localURL)
|
||||
downloadedFilePath = localURL.path
|
||||
print("[MaterialReader] Downloaded to: \(localURL.path), size: \(data.count)")
|
||||
vm.filePath = localURL.path
|
||||
}
|
||||
} catch {
|
||||
print("[MaterialReader] COS download failed: \(error.localizedDescription)")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user