Skip to content

Commit e833034

Browse files
committed
Updated internals of FridgeCompartment
1 parent c840c26 commit e833034

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

Sources/Fridge/FridgeCompartment.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,15 @@ internal struct FridgeCompartment {
6565
var alreadyExist: Bool {
6666
_fileManager.fileExists(atPath: objectURLPath.path)
6767
}
68-
69-
/// Removes compartment from persistent storage
70-
func remove() {
71-
if alreadyExist {
72-
try? _fileManager.removeItem(atPath: objectURLPath.path)
73-
}
74-
}
7568
}
7669

7770
extension FridgeCompartment {
7871
/// Tries to store object raw data to the system storage
7972
func store(data: Data) throws {
8073
// create file if it doesn't exist
81-
if !alreadyExist {
82-
_fileManager.createFile(atPath: objectURLPath.path, contents: data, attributes: nil)
74+
guard !alreadyExist else {
8375
print("*** \tCreating new file at: \(objectURLPath). Size: \(data.count) bytes")
76+
_fileManager.createFile(atPath: objectURLPath.path, contents: data, attributes: nil)
8477
return
8578
}
8679

@@ -97,4 +90,11 @@ extension FridgeCompartment {
9790
func load() throws -> Data {
9891
return try Data(contentsOf: objectURLPath)
9992
}
93+
94+
/// Removes compartment from persistent storage
95+
func remove() {
96+
if alreadyExist {
97+
try? _fileManager.removeItem(atPath: objectURLPath.path)
98+
}
99+
}
100100
}

0 commit comments

Comments
 (0)