@@ -27,6 +27,7 @@ struct AdvancedServerSettingsView: View {
2727 @State private var localFiles : [ URL ] = [ ]
2828 @State private var showOnlyLogFiles : Bool = true
2929 @State private var rotatingLogs : Bool = false
30+ @State private var showDeleteAllSB : Bool = false
3031 @State private var showLocalFilePicker : Bool = false
3132 @State private var showLocalFileContent : Bool = false
3233 @State private var selectedLocalFile : URL ?
@@ -168,6 +169,17 @@ struct AdvancedServerSettingsView: View {
168169 }
169170 }
170171
172+ func deleteAllSBFiles( ) -> ( Int , Int ) {
173+ let totalFiles = filteredLocalFiles. count
174+ var totalSize = 0
175+ for localFile in filteredLocalFiles {
176+ let fileSize = ( try ? FileManager . default. attributesOfItem ( atPath: localFile. path) ) ? [ . size] as? Int ?? 0
177+ totalSize += fileSize
178+ deleteLocalFile ( localFile)
179+ }
180+ return ( totalFiles, totalSize)
181+ }
182+
171183 private var showDeviceMetricsView : some View {
172184 NavigationView {
173185 MetricsView ( )
@@ -250,6 +262,25 @@ struct AdvancedServerSettingsView: View {
250262 }
251263 }
252264 }
265+ if !filteredLocalFiles. isEmpty {
266+ let deleteLabel = showOnlyLogFiles ? " Delete all log files " : " Delete all files "
267+ Button ( action: {
268+ showDeleteAllSB = true
269+ } ) {
270+ Label ( deleteLabel, systemImage: " trash " )
271+ }
272+ }
273+ }
274+ . alert ( " Are you sure? " , isPresented: $showDeleteAllSB) {
275+ Button ( " Delete " , role: . destructive) {
276+ let ( totalFiles, totalSize) = deleteAllSBFiles ( )
277+ let sizeDeleted = formatBytes ( Int64 ( totalSize) )
278+ let msg = " Deleted \( totalFiles) files of size \( sizeDeleted) "
279+ localFilesMessage = ToastMessagePayload (
280+ text: msg, color: . red, duration: 3
281+ )
282+ }
283+ Button ( " Cancel " , role: . cancel) { }
253284 }
254285 . navigationTitle ( " Sandbox Files " )
255286 . modifier ( ToastMessage ( payload: $localFilesMessage) )
0 commit comments