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?
|
@Published var stats: TextStats?
|
||||||
|
|
||||||
let materialId: String
|
let materialId: String
|
||||||
let filePath: String
|
var filePath: String
|
||||||
let materialType: MaterialType
|
let materialType: MaterialType
|
||||||
let mode: PreviewMode
|
let mode: PreviewMode
|
||||||
|
|
||||||
@ -109,19 +109,9 @@ struct MaterialReaderView: View {
|
|||||||
@Environment(\.scenePhase) private var scenePhase
|
@Environment(\.scenePhase) private var scenePhase
|
||||||
@State private var isParsing = false
|
@State private var isParsing = false
|
||||||
@State private var parseMessage = ""
|
@State private var parseMessage = ""
|
||||||
@State private var downloadedFilePath: String?
|
|
||||||
|
|
||||||
private let title: String
|
private let title: String
|
||||||
private let knowledgeBaseId: 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)
|
// V2 session manager (primary) + V1 collector (fallback)
|
||||||
private let sessionManager = ReadingRuntimeSessionManager.shared
|
private let sessionManager = ReadingRuntimeSessionManager.shared
|
||||||
private let collector = ReadingEventCollector.shared
|
private let collector = ReadingEventCollector.shared
|
||||||
@ -262,8 +252,8 @@ struct MaterialReaderView: View {
|
|||||||
let localURL = FileManager.default.temporaryDirectory
|
let localURL = FileManager.default.temporaryDirectory
|
||||||
.appendingPathComponent("source_\(vm.materialId).\(ext)")
|
.appendingPathComponent("source_\(vm.materialId).\(ext)")
|
||||||
try data.write(to: localURL)
|
try data.write(to: localURL)
|
||||||
downloadedFilePath = localURL.path
|
|
||||||
print("[MaterialReader] Downloaded to: \(localURL.path), size: \(data.count)")
|
print("[MaterialReader] Downloaded to: \(localURL.path), size: \(data.count)")
|
||||||
|
vm.filePath = localURL.path
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
print("[MaterialReader] COS download failed: \(error.localizedDescription)")
|
print("[MaterialReader] COS download failed: \(error.localizedDescription)")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user