fixed bug where ip_to_hash made a "node" dir for every node

This commit is contained in:
Roel 2014-04-24 17:41:52 +02:00
parent 50a52e447b
commit 590a4f5d98

View File

@ -47,7 +47,7 @@ class Meshenger:
sys.exit() sys.exit()
while True: while True:
print 'Entering main loop'
if len(self.devices) > 0: if len(self.devices) > 0:
print 'found', len(self.devices),'device(s)' print 'found', len(self.devices),'device(s)'
@ -186,11 +186,13 @@ Get new messages from other node based on it's index file
""" """
Convert a node's ip into a hash and make a directory to store it's files Convert a node's ip into a hash and make a directory to store it's files
""" """
if not os.path.exists('nodes'):
os.mkdir('nodes')
import hashlib import hashlib
hasj = hashlib.md5(ip).hexdigest() hasj = hashlib.md5(ip).hexdigest()
nodepath = os.path.join(os.path.abspath('nodes/'), hasj) nodepath = os.path.join(os.path.abspath('nodes'), hasj)
if not os.path.exists(nodepath): if not os.path.exists(nodepath):
os.mkdir('nodes')
os.mkdir(nodepath) os.mkdir(nodepath)
return nodepath return nodepath