Skip to content

Commit 4300f76

Browse files
Update storage.py
1 parent ebc57f1 commit 4300f76

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/storage.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@
55
class FileStorage:
66
def __init__(self, file_name):
77
self.fine_name = file_name
8+
self.history = {}
89

910
def save(self, data):
10-
with open(self.fine_name, 'a+', newline='') as f:
11-
json.dump(data, f)
11+
self.history.update(data)
12+
with open(self.fine_name, 'w', newline='') as f:
13+
json.dump(self.history, f)
1214

1315
def load(self):
1416
with open(self.fine_name, newline='') as jsonfile:
1517
data = json.load(jsonfile)
16-
return data
18+
self.history = data
19+
return self.history
1720

1821

1922
class MongoStorage:

0 commit comments

Comments
 (0)