-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't support transferring Ruuvi Station data on device change (#1852)
fixes #1848
- Loading branch information
1 parent
26601ad
commit df5e3ae
Showing
4 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
26 changes: 26 additions & 0 deletions
26
...ources/RuuviMigrationImpl/IsExcludedFromBackup/MigrationManagerIsExcludedFromBackup.swift
This file contains 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,26 @@ | ||
import Foundation | ||
import RuuviContext | ||
|
||
final class MigrationManagerIsExcludedFromBackup: RuuviMigration { | ||
private let sqliteContext: SQLiteContext | ||
|
||
init(sqliteContext: SQLiteContext) { | ||
self.sqliteContext = sqliteContext | ||
} | ||
|
||
func migrateIfNeeded() { | ||
let databaseUrl = NSURL(fileURLWithPath: sqliteContext.database.dbPath) | ||
do { | ||
let resourceValues = try databaseUrl.resourceValues(forKeys: [.isExcludedFromBackupKey]) | ||
guard resourceValues[.isExcludedFromBackupKey] == nil | ||
|| resourceValues[.isExcludedFromBackupKey] as? Bool == false else { | ||
return | ||
} | ||
try databaseUrl.setResourceValue(true, forKey: .isExcludedFromBackupKey) | ||
} catch let error as NSError { | ||
print("Error excluding \(databaseUrl.lastPathComponent ?? "") from backup \(error)") | ||
} | ||
} | ||
|
||
private let migratedUdKey = "MigrationManagerIsExcludedFromBackup.migrated" | ||
} |
This file contains 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
This file contains 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