From f731b101668425fe3d675442b765dac53c9e27e7 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Sun, 17 Sep 2017 14:19:45 +0200 Subject: fixed 'set user' when file isn't empty --- lib/commands.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib') diff --git a/lib/commands.py b/lib/commands.py index 663f231..942bc0e 100644 --- a/lib/commands.py +++ b/lib/commands.py @@ -19,8 +19,15 @@ class Commands(object): self.user = cmd[2] + with open(co['path'], 'rb') as fin: + listOld = [x.decode('utf-8') for x in fin.readlines()] + del listOld[0] + with open(co['path'], 'wb') as fout: fout.write((cmd[2] + '\n').encode('utf-8')) + for i in listOld: + fout.write((i).encode('utf-8')) + del listOld print('Ok') elif cmd[1] is not ListCommands.commands['set']: @@ -82,6 +89,7 @@ class Commands(object): try: with open(co['path'], 'ab') as fout: + fout.seek(1, 1) fout.write((msg + '\n').encode('utf-8')) print('Ok') -- cgit v1.2.3-18-g5258