@@ -9,6 +9,7 @@ import workmanager_apple
99 didFinishLaunchingWithOptions launchOptions: [ UIApplication . LaunchOptionsKey : Any ] ?
1010 ) -> Bool {
1111 GeneratedPluginRegistrant . register ( with: self )
12+ excludeSensitiveFilesFromBackup ( )
1213
1314 // workmanager_apple spawns a separate FlutterEngine per background task
1415 // (see BackgroundWorker.swift in workmanager_apple). Plugins registered
@@ -23,23 +24,22 @@ import workmanager_apple
2324 GeneratedPluginRegistrant . register ( with: registry)
2425 }
2526
26- WorkmanagerPlugin . registerPeriodicTask (
27- withIdentifier: " com.bullbitcoin.mobile.bitcoin-sync-id " ,
28- frequency: NSNumber ( value: 20 * 60 )
29- )
30- WorkmanagerPlugin . registerPeriodicTask (
31- withIdentifier: " com.bullbitcoin.mobile.liquid-sync-id " ,
32- frequency: NSNumber ( value: 20 * 60 )
33- )
34- WorkmanagerPlugin . registerPeriodicTask (
35- withIdentifier: " com.bullbitcoin.mobile.swaps-sync-id " ,
36- frequency: NSNumber ( value: 20 * 60 )
37- )
38- WorkmanagerPlugin . registerPeriodicTask (
39- withIdentifier: " com.bullbitcoin.mobile.logs-prune-id " ,
40- frequency: NSNumber ( value: 20 * 60 )
41- )
42-
4327 return super. application ( application, didFinishLaunchingWithOptions: launchOptions)
4428 }
29+
30+ private func excludeSensitiveFilesFromBackup( ) {
31+ let fileManager = FileManager . default
32+ guard let documentsDirectory = fileManager. urls ( for: . documentDirectory, in: . userDomainMask) . first else {
33+ return
34+ }
35+
36+ // Wallet, payjoin, wallet-engine, and TSV log data all live below Documents.
37+ // Excluding the directory also covers wallet directories created after startup.
38+ var documentsURL = documentsDirectory
39+ var resourceValues = URLResourceValues ( )
40+ resourceValues. isExcludedFromBackup = true
41+ // `setResourceValues` is `mutating`, so it needs a `var` receiver.
42+ // URLResourceValues.isExcludedFromBackup sets NSURLIsExcludedFromBackupKey.
43+ try ? documentsURL. setResourceValues ( resourceValues)
44+ }
4545}
0 commit comments