WIP: demo app

This commit is contained in:
John Rommel Estropia
2016-07-25 08:21:22 +09:00
parent db5b8ca702
commit e9be711d4c
61 changed files with 210 additions and 298 deletions

View File

@@ -57,7 +57,6 @@ public class ICloudStore: CloudStorage {
}
)
```
- parameter ubiquitousContentName: the name of the store in iCloud. This is required and should not be empty, and should not contain periods (`.`).
- parameter ubiquitousContentTransactionLogsSubdirectory: an optional subdirectory path for the transaction logs
- parameter ubiquitousContainerID: a container if your app has multiple ubiquity container identifiers in its entitlements
@@ -481,8 +480,8 @@ public class ICloudStore: CloudStorage {
guard let `self` = self,
let observer = observer,
let dataStack = note.userInfo?[String(DataStack.self)] as? DataStack
where self.dataStack === dataStack else {
let dataStack = note.userInfo?[String(DataStack.self)] as? DataStack,
self.dataStack === dataStack else {
return
}

View File

@@ -25,6 +25,9 @@
import Foundation
import CoreData
#if USE_FRAMEWORKS
import GCDKit
#endif
// MARK: - LegacySQLiteStore
@@ -180,7 +183,29 @@ public final class LegacySQLiteStore: LocalStorage, DefaultInitializableStore {
options: [NSSQLitePragmasOption: ["journal_mode": "DELETE"]]
)
try journalUpdatingCoordinator.remove(store)
try FileManager.default.removeItem(at: fileURL)
let fileManager = FileManager.default
do {
let temporaryFile = try URL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first!)
.appendingPathComponent(Bundle.main.bundleIdentifier ?? "com.CoreStore.DataStack", isDirectory: true)
.appendingPathComponent("trash", isDirectory: true)
.appendingPathComponent(UUID().uuidString, isDirectory: false)
try fileManager.createDirectory(
at: try temporaryFile.deletingLastPathComponent(),
withIntermediateDirectories: true,
attributes: nil
)
try fileManager.moveItem(at: fileURL, to: temporaryFile)
GCDQueue.background.async {
_ = try? fileManager.removeItem(at: temporaryFile)
}
}
catch {
try fileManager.removeItem(at: fileURL)
}
}
}

View File

@@ -24,6 +24,9 @@
//
import CoreData
#if USE_FRAMEWORKS
import GCDKit
#endif
// MARK: - SQLiteStore
@@ -177,7 +180,29 @@ public final class SQLiteStore: LocalStorage, DefaultInitializableStore {
options: [NSSQLitePragmasOption: ["journal_mode": "DELETE"]]
)
try journalUpdatingCoordinator.remove(store)
try FileManager.default.removeItem(at: fileURL)
let fileManager = FileManager.default
do {
let temporaryFile = try URL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first!)
.appendingPathComponent(Bundle.main.bundleIdentifier ?? "com.CoreStore.DataStack", isDirectory: true)
.appendingPathComponent("trash", isDirectory: true)
.appendingPathComponent(UUID().uuidString, isDirectory: false)
try fileManager.createDirectory(
at: try temporaryFile.deletingLastPathComponent(),
withIntermediateDirectories: true,
attributes: nil
)
try fileManager.moveItem(at: fileURL, to: temporaryFile)
GCDQueue.background.async {
_ = try? fileManager.removeItem(at: temporaryFile)
}
}
catch {
try fileManager.removeItem(at: fileURL)
}
}
}