added support for multiple files in the client and made the file reading less memory intensive for the server (poorly, mind you)

This commit is contained in:
jchu 2004-09-02 21:15:10 +00:00
parent 2423a686d6
commit a4710414e0
2 changed files with 17 additions and 8 deletions

View file

@ -121,14 +121,16 @@ def main(argv=None):
usage()
return 1
files = []
for i in argv[1:]:
try:
fil = ClientFile(argv[1])
files.append(ClientFile(i))
except IOError, err:
print "Error: " + err.strerror + ": '" + err.filename + "'"
usage()
return 1
cs = ClientSocket([fil], 'localhost', 1034, "bfinch@example.net", "B0b")
cs = ClientSocket(files, 'localhost', 1034, "bfinch@example.net", "B0b")
cs.connect()
if not cs.auth():

View file

@ -108,7 +108,14 @@ class ClientSocket(threading.Thread):
def readFiles(self):
for i in self.files:
i.fd.write(self.reliableRead(i.actual_size))
count = 0
while count != i.actual_size:
if count + 1024 > i.actual_size:
i.fd.write(self.reliableRead(i.actual_size - count))
count += i.actual_size - count
else:
i.fd.write(self.reliableRead(1024))
count += 1024
i.fd.flush()
reply = {'numpkgs': len(self.files)}
for i, v in enumerate(self.files):