Skip to content

Commit 75cd283

Browse files
committed
Revert the changes of CreamAsset
1 parent fefdfb2 commit 75cd283

File tree

1 file changed

+5
-34
lines changed

1 file changed

+5
-34
lines changed

IceCream/Classes/CreamAsset.swift

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,12 @@ public class CreamAsset: Object {
2323
override public static func ignoredProperties() -> [String] {
2424
return ["data", "filePath"]
2525
}
26-
27-
private convenience init(empty: Bool) {
28-
self.init()
29-
self.data = nil
30-
}
3126

32-
private convenience init(objectID: String, propName: String, data: Data, force: Bool = false) {
27+
private convenience init(objectID: String, propName: String, data: Data) {
3328
self.init()
3429
self.data = data
3530
self.uniqueFileName = "\(objectID)_\(propName)"
36-
37-
save(data: data, to: uniqueFileName, force: force)
31+
save(data: data, to: uniqueFileName)
3832
}
3933

4034
private convenience init?(objectID: String, propName: String, url: URL) {
@@ -53,9 +47,8 @@ public class CreamAsset: Object {
5347
return CreamAsset.creamAssetDefaultURL().appendingPathComponent(uniqueFileName)
5448
}
5549

56-
private func save(data: Data, to path: String, force: Bool = false) {
50+
func save(data: Data, to path: String) {
5751
let url = CreamAsset.creamAssetDefaultURL().appendingPathComponent(path)
58-
if FileManager.default.fileExists(atPath: url.path), !force { return }
5952
do {
6053
try data.write(to: url)
6154
} catch {
@@ -68,11 +61,6 @@ public class CreamAsset: Object {
6861
return CKAsset(fileURL: filePath)
6962
}
7063
}
71-
72-
/// An empty CreamAsset, useful if you're not storing anything
73-
public static var empty: CreamAsset {
74-
return CreamAsset(empty: true)
75-
}
7664

7765
/// Parses a CKRecord and CKAsset back into a CreamAsset
7866
///
@@ -84,35 +72,18 @@ public class CreamAsset: Object {
8472
static func parse(from propName: String, record: CKRecord, asset: CKAsset) -> CreamAsset? {
8573
return CreamAsset(objectID: record.recordID.recordName, propName: propName, url: asset.fileURL)
8674
}
87-
88-
/// Creates a new CreamAsset for the given object id with Data
89-
///
90-
/// - Parameters:
91-
/// - objectID: The object ID (key property of the Realm object) the asset will live on
92-
/// - propName: The unique property name to identify this asset. e.g.: Dog Object may have multiple CreamAsset properties, so we need unique `propName`s to identify these.
93-
/// - data: The file data
94-
/// - force: Whether to force a new save, even if the file already exists
95-
/// - Returns: A CreamAsset if it was successful
96-
public static func create(objectID: String, propName: String, data: Data, force: Bool = false) -> CreamAsset? {
97-
return CreamAsset(objectID: objectID,
98-
propName: propName,
99-
data: data,
100-
force: force)
101-
}
10275

10376
/// Creates a new CreamAsset for the given object with Data
10477
///
10578
/// - Parameters:
10679
/// - object: The object the asset will live on
10780
/// - propName: The unique property name to identify this asset. e.g.: Dog Object may have multiple CreamAsset properties, so we need unique `propName`s to identify these.
10881
/// - data: The file data
109-
/// - force: Whether to force a new save, even if the file already exists
11082
/// - Returns: A CreamAsset if it was successful
111-
public static func create(object: CKRecordConvertible, propName: String, data: Data, force: Bool = false) -> CreamAsset? {
83+
public static func create(object: CKRecordConvertible, propName: String, data: Data) -> CreamAsset? {
11284
return CreamAsset(objectID: object.recordID.recordName,
11385
propName: propName,
114-
data: data,
115-
force: force)
86+
data: data)
11687
}
11788

11889
/// Creates a new CreamAsset for the given object with a URL

0 commit comments

Comments
 (0)