From 841806b2a44d6611624d1a05ea8942c38bd09cf1 Mon Sep 17 00:00:00 2001 From: ryo_saeba Date: Mon, 7 May 2007 18:25:02 +0000 Subject: [PATCH] Force sync so file is valid. git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@6201 282e977c-c81d-0410-88c4-b93c2d0d6712 --- python/CFBank.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/CFBank.py b/python/CFBank.py index ec0cdacf6..82a940fbe 100644 --- a/python/CFBank.py +++ b/python/CFBank.py @@ -29,8 +29,8 @@ class CFBank: bankdb = {} def __init__(self, bankfile): - self.bankdb_file = os.path.join(Crossfire.LocalDirectory(),bankfile) - self.bankdb = shelve.open(self.bankdb_file) + self.bankdb_file = os.path.join(Crossfire.LocalDirectory(), bankfile) + self.bankdb = shelve.open(self.bankdb_file, writeback=True) def deposit(self, user, amount): if not self.bankdb.has_key(user): @@ -38,12 +38,14 @@ class CFBank: else: temp=self.bankdb[user] self.bankdb[user]=temp+amount + self.bankdb.sync() def withdraw(self, user, amount): if self.bankdb.has_key(user): if (self.bankdb[user] >= amount): temp=self.bankdb[user] self.bankdb[user]=temp-amount + self.bankdb.sync() return 1 return 0 @@ -57,6 +59,7 @@ class CFBank: if self.bankdb.has_key(user): del self.bankdb[user] print "%s's bank account removed." %user + self.bankdb.sync() return 1 else: return 0