Resets previous Harmony beta database upon first launch
This commit is contained in:
parent
de616021e2
commit
9bebfd6415
@ -103,6 +103,7 @@
|
||||
BF6BF3271EB87EB8008E83CD /* PhotoLibraryImportOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF6BF3261EB87EB8008E83CD /* PhotoLibraryImportOption.swift */; };
|
||||
BF6EE5E91F7C5F860051AD6C /* _GameControllerInputMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF6EE5E81F7C5F860051AD6C /* _GameControllerInputMapping.swift */; };
|
||||
BF6EE5EB1F7C5F8F0051AD6C /* GameControllerInputMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF6EE5EA1F7C5F8F0051AD6C /* GameControllerInputMapping.swift */; };
|
||||
BF713C0822499ED4004A1A2B /* PreviousHarmony.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = BF713C0622499ED3004A1A2B /* PreviousHarmony.xcdatamodeld */; };
|
||||
BF71CF871FE90006001F1613 /* AppIconShortcutsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF71CF861FE90006001F1613 /* AppIconShortcutsViewController.swift */; };
|
||||
BF71CF8A1FE904B1001F1613 /* GameTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = BF71CF891FE904B1001F1613 /* GameTableViewCell.xib */; };
|
||||
BF797A2D1C2D339F00F1A000 /* UILabel+FontSize.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF797A2C1C2D339F00F1A000 /* UILabel+FontSize.swift */; };
|
||||
@ -277,6 +278,7 @@
|
||||
BF6EE5E81F7C5F860051AD6C /* _GameControllerInputMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = _GameControllerInputMapping.swift; sourceTree = "<group>"; };
|
||||
BF6EE5EA1F7C5F8F0051AD6C /* GameControllerInputMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameControllerInputMapping.swift; sourceTree = "<group>"; };
|
||||
BF70798B1B6B464B0019077C /* ZipZap.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = ZipZap.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
BF713C0722499ED3004A1A2B /* Harmony.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Harmony.xcdatamodel; sourceTree = "<group>"; };
|
||||
BF71CF861FE90006001F1613 /* AppIconShortcutsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppIconShortcutsViewController.swift; sourceTree = "<group>"; };
|
||||
BF71CF891FE904B1001F1613 /* GameTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = GameTableViewCell.xib; sourceTree = "<group>"; };
|
||||
BF797A2C1C2D339F00F1A000 /* UILabel+FontSize.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UILabel+FontSize.swift"; sourceTree = "<group>"; };
|
||||
@ -485,6 +487,7 @@
|
||||
BF5942711E09BC690051894B /* Model */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BF713C0622499ED3004A1A2B /* PreviousHarmony.xcdatamodeld */,
|
||||
BF4828811F9027B600028B97 /* Delta.xcdatamodeld */,
|
||||
BF5942741E09BC740051894B /* Human */,
|
||||
BF5942751E09BC780051894B /* Machine */,
|
||||
@ -877,6 +880,7 @@
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
English,
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
@ -1069,6 +1073,7 @@
|
||||
BF4828861F9028F500028B97 /* System.swift in Sources */,
|
||||
BF13A7561D5D29B0000BB055 /* PreviewGameViewController.swift in Sources */,
|
||||
BF6866171DCAC8B900BF2D06 /* ControllerSkin+Configuring.swift in Sources */,
|
||||
BF713C0822499ED4004A1A2B /* PreviousHarmony.xcdatamodeld in Sources */,
|
||||
BF59427D1E09BC830051894B /* ControllerSkin.swift in Sources */,
|
||||
BFAB9F7D219A43380080EC7D /* SyncManager.swift in Sources */,
|
||||
BFCEA67E1D56FF640061A534 /* UIViewControllerContextTransitioning+Conveniences.swift in Sources */,
|
||||
@ -1350,6 +1355,16 @@
|
||||
sourceTree = "<group>";
|
||||
versionGroupType = wrapper.xcdatamodel;
|
||||
};
|
||||
BF713C0622499ED3004A1A2B /* PreviousHarmony.xcdatamodeld */ = {
|
||||
isa = XCVersionGroup;
|
||||
children = (
|
||||
BF713C0722499ED3004A1A2B /* Harmony.xcdatamodel */,
|
||||
);
|
||||
currentVersion = BF713C0722499ED3004A1A2B /* Harmony.xcdatamodel */;
|
||||
path = PreviousHarmony.xcdatamodeld;
|
||||
sourceTree = "<group>";
|
||||
versionGroupType = wrapper.xcdatamodel;
|
||||
};
|
||||
/* End XCVersionGroup section */
|
||||
};
|
||||
rootObject = BFFA71CF1AAC406100EE9DD1 /* Project object */;
|
||||
|
||||
@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="14490.78" systemVersion="18C54" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
|
||||
<entity name="LocalRecord" representedClassName="LocalRecord" syncable="YES">
|
||||
<attribute name="modificationDate" attributeType="Date" syncable="YES"/>
|
||||
<attribute name="recordedObjectIdentifier" attributeType="String" syncable="YES"/>
|
||||
<attribute name="recordedObjectType" attributeType="String" syncable="YES"/>
|
||||
<attribute name="recordedObjectURI" attributeType="URI" syncable="YES"/>
|
||||
<attribute name="status" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
|
||||
<attribute name="versionDate" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
|
||||
<attribute name="versionIdentifier" optional="YES" attributeType="String" syncable="YES"/>
|
||||
<relationship name="managedRecord" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="ManagedRecord" inverseName="localRecord" inverseEntity="ManagedRecord" syncable="YES"/>
|
||||
<relationship name="remoteFiles" toMany="YES" deletionRule="Cascade" destinationEntity="RemoteFile" inverseName="localRecord" inverseEntity="RemoteFile" syncable="YES"/>
|
||||
<uniquenessConstraints>
|
||||
<uniquenessConstraint>
|
||||
<constraint value="recordedObjectType"/>
|
||||
<constraint value="recordedObjectIdentifier"/>
|
||||
</uniquenessConstraint>
|
||||
</uniquenessConstraints>
|
||||
</entity>
|
||||
<entity name="ManagedRecord" representedClassName="ManagedRecord" syncable="YES">
|
||||
<attribute name="isConflicted" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
|
||||
<attribute name="isSyncingEnabled" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/>
|
||||
<attribute name="recordedObjectIdentifier" attributeType="String" syncable="YES"/>
|
||||
<attribute name="recordedObjectType" attributeType="String" syncable="YES"/>
|
||||
<relationship name="localRecord" optional="YES" maxCount="1" deletionRule="Cascade" destinationEntity="LocalRecord" inverseName="managedRecord" inverseEntity="LocalRecord" syncable="YES"/>
|
||||
<relationship name="remoteRecord" optional="YES" maxCount="1" deletionRule="Cascade" destinationEntity="RemoteRecord" inverseName="managedRecord" inverseEntity="RemoteRecord" syncable="YES"/>
|
||||
<fetchIndex name="byRecordedObject">
|
||||
<fetchIndexElement property="recordedObjectType" type="Binary" order="ascending"/>
|
||||
<fetchIndexElement property="recordedObjectIdentifier" type="Binary" order="ascending"/>
|
||||
</fetchIndex>
|
||||
<uniquenessConstraints>
|
||||
<uniquenessConstraint>
|
||||
<constraint value="recordedObjectType"/>
|
||||
<constraint value="recordedObjectIdentifier"/>
|
||||
</uniquenessConstraint>
|
||||
</uniquenessConstraints>
|
||||
</entity>
|
||||
<entity name="RemoteFile" representedClassName="RemoteFile" syncable="YES">
|
||||
<attribute name="identifier" attributeType="String" syncable="YES"/>
|
||||
<attribute name="remoteIdentifier" attributeType="String" syncable="YES"/>
|
||||
<attribute name="sha1Hash" attributeType="String" syncable="YES"/>
|
||||
<attribute name="size" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
|
||||
<attribute name="versionIdentifier" attributeType="String" syncable="YES"/>
|
||||
<relationship name="localRecord" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="LocalRecord" inverseName="remoteFiles" inverseEntity="LocalRecord" syncable="YES"/>
|
||||
</entity>
|
||||
<entity name="RemoteRecord" representedClassName="RemoteRecord" syncable="YES">
|
||||
<attribute name="author" optional="YES" attributeType="String" syncable="YES"/>
|
||||
<attribute name="identifier" attributeType="String" syncable="YES"/>
|
||||
<attribute name="isLocked" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
|
||||
<attribute name="localizedName" optional="YES" attributeType="String" syncable="YES"/>
|
||||
<attribute name="metadata" optional="YES" attributeType="Transformable" syncable="YES"/>
|
||||
<attribute name="previousVersionDate" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
|
||||
<attribute name="previousVersionIdentifier" optional="YES" attributeType="String" syncable="YES"/>
|
||||
<attribute name="recordedObjectIdentifier" attributeType="String" syncable="YES"/>
|
||||
<attribute name="recordedObjectType" attributeType="String" syncable="YES"/>
|
||||
<attribute name="status" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
|
||||
<attribute name="versionDate" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
|
||||
<attribute name="versionIdentifier" attributeType="String" syncable="YES"/>
|
||||
<relationship name="managedRecord" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="ManagedRecord" inverseName="remoteRecord" inverseEntity="ManagedRecord" syncable="YES"/>
|
||||
<fetchIndex name="byIdentifier">
|
||||
<fetchIndexElement property="identifier" type="Binary" order="ascending"/>
|
||||
</fetchIndex>
|
||||
<uniquenessConstraints>
|
||||
<uniquenessConstraint>
|
||||
<constraint value="recordedObjectType"/>
|
||||
<constraint value="recordedObjectIdentifier"/>
|
||||
</uniquenessConstraint>
|
||||
</uniquenessConstraints>
|
||||
</entity>
|
||||
<configuration name="External"/>
|
||||
<configuration name="Harmony">
|
||||
<memberEntity name="ManagedRecord"/>
|
||||
<memberEntity name="LocalRecord"/>
|
||||
<memberEntity name="RemoteRecord"/>
|
||||
<memberEntity name="RemoteFile"/>
|
||||
</configuration>
|
||||
<elements>
|
||||
<element name="LocalRecord" positionX="93.01953125" positionY="273.0234375" width="128" height="180"/>
|
||||
<element name="ManagedRecord" positionX="298.4375" positionY="225.49609375" width="128" height="133"/>
|
||||
<element name="RemoteFile" positionX="288" positionY="378" width="128" height="135"/>
|
||||
<element name="RemoteRecord" positionX="488.2578125" positionY="272.56640625" width="128" height="240"/>
|
||||
</elements>
|
||||
</model>
|
||||
@ -10,6 +10,11 @@ import Harmony
|
||||
import Harmony_Drive
|
||||
import Harmony_Dropbox
|
||||
|
||||
private extension UserDefaults
|
||||
{
|
||||
@NSManaged var didValidateHarmonyBetaDatabase: Bool
|
||||
}
|
||||
|
||||
extension SyncManager
|
||||
{
|
||||
enum RecordType: String, Hashable
|
||||
@ -118,6 +123,31 @@ extension SyncManager
|
||||
guard let service = service else { return completionHandler(.success) }
|
||||
|
||||
let coordinator = SyncCoordinator(service: service.service, persistentContainer: DatabaseManager.shared)
|
||||
|
||||
if !UserDefaults.standard.didValidateHarmonyBetaDatabase
|
||||
{
|
||||
UserDefaults.standard.didValidateHarmonyBetaDatabase = true
|
||||
|
||||
coordinator.deauthenticate { (result) in
|
||||
do
|
||||
{
|
||||
try FileManager.default.removeItem(at: RecordController.defaultDirectoryURL())
|
||||
}
|
||||
catch CocoaError.fileNoSuchFile
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
catch
|
||||
{
|
||||
print("Failed to remove Harmony database.", error)
|
||||
}
|
||||
|
||||
self.start(service: service, completionHandler: completionHandler)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
coordinator.start { (result) in
|
||||
do
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user