-
Notifications
You must be signed in to change notification settings - Fork 0
connection recovery feature #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
harutiro
wants to merge
31
commits into
main
Choose a base branch
from
feature/retry-connection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
e31c357
connection recovery feature
harutiro 4c1963f
feat: Add functionality to clear data for specific tag and navigate b…
harutiro bc76b39
feat: Update tag navigation logic to allow returning to the last comp…
harutiro 8585672
feat: Implement antenna pairing management and integrate with Connect…
harutiro 5143e8c
feat: Add antenna ID management and coordinate transformation for rea…
harutiro 3792426
Refactor FloorMap and Antenna Positioning Logic
harutiro 66ef89f
refactor: Remove ProjectProgress model and related repository methods
harutiro db4ad67
fix: Adjust azimuth angle conversion for polar to Cartesian transform…
harutiro bc615d7
feat: Add sessionId to PersistentRealtimeData and update related func…
harutiro 179e4d5
feat: 複数アンテナ対応のデータ管理機能を追加し、CSVエクスポート機能を強化
harutiro 429fa3f
fix: 修正されたプロパティアクセスを使用してメッセージ送信とデータマップ更新のロジックを改善
harutiro d3f1cc3
feat: NLOS検出機能を追加し、UIに警告表示を実装
harutiro d8de131
feat: createSessionDirectoryのcustomName引数を必須に変更し、ファイル名の保存とエクスポート処理を改善
harutiro c290c12
feat: リアルタイムデータ表示のトグル機能を追加し、UIのアニメーションを改善
harutiro fb493fa
feat: navigateToメソッドにスタックリセットオプションを追加し、データコレクション画面に戻るボタンを実装
harutiro 01b1c43
fix: iOSと他のプラットフォームでのナビゲーションバーのボタン配置を条件付きで修正
harutiro 3deccdf
feat: ZIP圧縮機能を持つZipFileManagerとセッションデータエクスポート用のUseCaseを追加し、データ表示画面に共有…
harutiro 99398bf
feat: セッションデータ削除機能を追加し、データ表示画面に削除確認アラートを実装
harutiro 74d1ae3
refactor: 不要なファイル管理機能を削除し、表示モードを簡素化
harutiro 6e7a3f4
refactor: NavigationViewをVStackに変更し、SettingsViewのレイアウトを簡素化
harutiro 845bbef
fix: フロアマップ情報の保存処理を修正し、SensingFlowNavigatorの検証に必要な情報を保存するように変更
harutiro fddd23d
feat: タグ表示モードを追加し、リアルタイム位置表示を個別表示と統合表示に切り替え可能に
harutiro 2153560
fix: アンテナの回転角度を修正し、表示用の回転角度を追加
harutiro d4da821
fix: アンテナ回転コントロールの表示角度計算を修正し、ボタンアクションを調整
harutiro 9e1e104
feat: 座標変換と重心計算のロジックを改善し、ローパスフィルターを追加
harutiro 0c333fc
feat: Enhance Sensor Data Processing with IQR Outlier Detection
harutiro 83f3139
feat: アンテナに紐づいたデバイスのデータ収集ロジックを改善し、エラーハンドリングを追加
harutiro a79be6e
キャリブレションをするときに動作が不安定になる 問題を解決。キャリブレーションをする端末だけをセンシングするように変更
harutiro c5ce0cd
Implement automatic reconnection handling in AutoAntennaCalibration, …
harutiro 8ca782c
feat: 統合座標履歴の管理とCSVエクスポート機能を追加
harutiro 39e4415
feat: 接続の安定化とペアリング情報の検証・復元機能を追加
harutiro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,174 @@ | ||
| // | ||
| // ZipFileManager.swift | ||
| // UWBViewerSystem | ||
| // | ||
| // Created by Claude Code on 2025/11/25. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| /// ZIP圧縮処理を担当するファイルマネージャー | ||
| /// Devices層のFile管理機能として、ディレクトリのZIP圧縮を提供 | ||
| class ZipFileManager { | ||
| static let shared = ZipFileManager() | ||
|
|
||
| private init() {} | ||
|
|
||
| /// ディレクトリをZIP圧縮する | ||
| /// - Parameters: | ||
| /// - sourceURL: 圧縮するディレクトリのURL | ||
| /// - zipFileName: 作成するZIPファイルの名前 | ||
| /// - destinationDirectory: ZIPファイルを配置するディレクトリ(デフォルトは一時ディレクトリ) | ||
| /// - Returns: 作成されたZIPファイルのURL | ||
| /// - Throws: ファイル操作に関連するエラー | ||
| func zipDirectory( | ||
| at sourceURL: URL, | ||
| to zipFileName: String, | ||
| in destinationDirectory: URL? = nil | ||
| ) throws -> URL { | ||
| let destDir = destinationDirectory ?? FileManager.default.temporaryDirectory | ||
| let zipURL = destDir.appendingPathComponent(zipFileName) | ||
|
|
||
| // 既存のZIPファイルを削除 | ||
| try? FileManager.default.removeItem(at: zipURL) | ||
|
|
||
| // ZIP圧縮を実行 | ||
| let coordinator = NSFileCoordinator() | ||
| var coordinationError: NSError? | ||
|
|
||
| coordinator.coordinate( | ||
| readingItemAt: sourceURL, | ||
| options: .forUploading, | ||
| error: &coordinationError | ||
| ) { zipFileURL in | ||
| do { | ||
| try FileManager.default.copyItem(at: zipFileURL, to: zipURL) | ||
| print("📦 ZIP圧縮成功: \(zipURL.path)") | ||
| } catch { | ||
| print("❌ ZIP作成エラー: \(error)") | ||
| } | ||
| } | ||
|
|
||
| if let error = coordinationError { | ||
| throw error | ||
| } | ||
|
|
||
| return zipURL | ||
| } | ||
|
|
||
| /// 一時ディレクトリにファイルをコピーし、ZIP圧縮する | ||
| /// - Parameters: | ||
| /// - files: コピーするファイルのURL配列 | ||
| /// - zipFileName: 作成するZIPファイルの名前 | ||
| /// - tempDirectoryName: 一時ディレクトリの名前(デフォルトはランダムUUID) | ||
| /// - Returns: 作成されたZIPファイルのURL | ||
| /// - Throws: ファイル操作に関連するエラー | ||
| func zipFiles( | ||
| _ files: [URL], | ||
| to zipFileName: String, | ||
| tempDirectoryName: String? = nil | ||
| ) throws -> URL { | ||
| // 一時ディレクトリを作成 | ||
| let tempDirName = tempDirectoryName ?? UUID().uuidString | ||
| let tempDir = FileManager.default.temporaryDirectory | ||
| .appendingPathComponent(tempDirName, isDirectory: true) | ||
|
|
||
| try FileManager.default.createDirectory( | ||
| at: tempDir, | ||
| withIntermediateDirectories: true | ||
| ) | ||
|
|
||
| // ファイルをコピー | ||
| for fileURL in files { | ||
| let fileName = fileURL.lastPathComponent | ||
| let destinationURL = tempDir.appendingPathComponent(fileName) | ||
| try FileManager.default.copyItem(at: fileURL, to: destinationURL) | ||
| print("📄 ファイルコピー: \(fileName)") | ||
| } | ||
|
|
||
| // ZIP圧縮 | ||
| let zipURL = try zipDirectory(at: tempDir, to: zipFileName) | ||
|
|
||
| // 一時ディレクトリを削除 | ||
| try? FileManager.default.removeItem(at: tempDir) | ||
|
|
||
| return zipURL | ||
| } | ||
|
|
||
| /// ディレクトリ内の全ファイルをZIP圧縮する | ||
| /// - Parameters: | ||
| /// - directoryURL: 圧縮するディレクトリのURL | ||
| /// - zipFileName: 作成するZIPファイルの名前 | ||
| /// - includeMetadata: メタデータJSONを含めるかどうか | ||
| /// - metadata: 含めるメタデータ(includeMetadataがtrueの場合) | ||
| /// - Returns: 作成されたZIPファイルのURL、ディレクトリが存在しない場合はnil | ||
| /// - Throws: ファイル操作に関連するエラー | ||
| func zipDirectoryContents( | ||
| at directoryURL: URL, | ||
| to zipFileName: String, | ||
| includeMetadata: Bool = false, | ||
| metadata: [String: Any]? = nil | ||
| ) throws -> URL? { | ||
| // ディレクトリの存在確認 | ||
| guard FileManager.default.fileExists(atPath: directoryURL.path) else { | ||
| print("⚠️ 指定されたディレクトリが存在しません: \(directoryURL.path)") | ||
| return nil | ||
| } | ||
|
|
||
| // 一時ディレクトリを作成 | ||
| let tempDir = FileManager.default.temporaryDirectory | ||
| .appendingPathComponent(UUID().uuidString, isDirectory: true) | ||
|
|
||
| try FileManager.default.createDirectory( | ||
| at: tempDir, | ||
| withIntermediateDirectories: true | ||
| ) | ||
|
|
||
| // ディレクトリ内の全ファイルをコピー | ||
| let fileManager = FileManager.default | ||
| let files = try fileManager.contentsOfDirectory( | ||
| at: directoryURL, | ||
| includingPropertiesForKeys: nil | ||
| ) | ||
|
|
||
| var copiedFileCount = 0 | ||
| for fileURL in files { | ||
| let fileName = fileURL.lastPathComponent | ||
| let destinationURL = tempDir.appendingPathComponent(fileName) | ||
| try fileManager.copyItem(at: fileURL, to: destinationURL) | ||
| print("📄 ファイルコピー: \(fileName)") | ||
| copiedFileCount += 1 | ||
| } | ||
|
|
||
| print("✅ \(copiedFileCount)個のファイルをコピーしました") | ||
|
|
||
| // メタデータJSONを追加 | ||
| if includeMetadata, let metadata { | ||
| let jsonData = try JSONSerialization.data( | ||
| withJSONObject: metadata, | ||
| options: .prettyPrinted | ||
| ) | ||
| let metadataURL = tempDir.appendingPathComponent("metadata.json") | ||
| try jsonData.write(to: metadataURL) | ||
| print("📄 メタデータJSON作成完了: \(metadataURL.path)") | ||
| } | ||
|
|
||
| // ZIP圧縮 | ||
| print("🗜️ ZIP圧縮開始") | ||
| let zipURL = try zipDirectory(at: tempDir, to: zipFileName) | ||
| print("🗜️ ZIP圧縮完了: \(zipURL.path)") | ||
|
|
||
| // ZIPファイルの存在確認 | ||
| if FileManager.default.fileExists(atPath: zipURL.path) { | ||
| let attributes = try? FileManager.default.attributesOfItem(atPath: zipURL.path) | ||
| let fileSize = attributes?[.size] as? Int64 ?? 0 | ||
| print("✅ ZIPファイル確認OK: サイズ=\(fileSize)バイト") | ||
| } | ||
|
|
||
| // 一時ディレクトリを削除 | ||
| try? FileManager.default.removeItem(at: tempDir) | ||
| print("🗑️ 一時ディレクトリ削除完了") | ||
|
|
||
| return zipURL | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
zipDirectoryでZIP作成に失敗してもURLを返してしまう可能性がありますNSFileCoordinator内のcopyItemでエラーが発生してもprintするだけで、zipDirectory自体は常にzipURLを返しています。その結果、実際には存在しない(または壊れた)ZIPファイルのURLを上位が扱うリスクがあります。coordinationErrorとは別にcopyErrorを捕捉してthrowする、あるいはFileManager.default.fileExists(atPath: zipURL.path)で存在確認して、存在しない場合はエラーを投げるようにすると堅牢になります。Length of output: 5446
🏁 Script executed:
Length of output: 5143
🏁 Script executed:
Length of output: 3707
zipDirectoryでZIP作成に失敗してもURLを返してしまう可能性がありますNSFileCoordinator内のcopyItemでエラーが発生しても、44~47行目のcatchブロックでprintするだけで、エラーが捕捉されず、zipDirectory自体は常にzipURLを返しています。その結果、実際には存在しない(または壊れた)ZIPファイルのURLを上位(zipFilesやzipDirectoryContentsなど)が受け取るリスクがあります。coordinationErrorと同様にcopyErrorを捕捉し、ブロック後にthrowする必要があります。🤖 Prompt for AI Agents