I got a problem with httpClient. I took my code from the manual, but I used downloadToFile.
After downloading file from a http server, they are locked by a processus, and when I try to execute an .exe, I got an error message, because the file is locked by another processus.
At my mind, when I download the file via the channel, it locks the file, and not free it. I don’t know how to close the channel, or what I need to free my file:
if self.http==None: self.http = HTTPClient() self.channel = self.http.makeChannel(True) self.channel.setPersistentConnection(False) self.channel.beginGetDocument(DocumentSpec('http://localhost/updater/ressources/' + self.files[self.iterFile].replace("\\","/"))) ff=Filename(self.convDirectory + "/" + self.files[self.iterFile].replace("\\","/")) self.createTree(self.directory+self.files[self.iterFile]) self.channel.downloadToFile(ff) if not self.channel.isDownloadComplete(): print "Error downloading file." + self.channel.getStatusString() + str(self.channel.getStatusCode()) return task.done elif self.channel.isDownloadComplete(): fileHandle = open ( "./update.txt", 'a+' ) fileHandle.write("file="+str(self.files[self.iterFile])+ "\n") fileHandle.close() self.iterFile+=1
I think on the case of isDownloadComplete, I have to do something to close the channel.