File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
7770extension 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 ( " *** \t Creating 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}
You can’t perform that action at this time.
0 commit comments