hi,

the way file resume is implemented in DccFileReceive requires to user to determine the file size manually and set _resumeOffset. wouldnt it make sene to just kill the last few bytes of the file and resume it?

below is the current connectionMade method from:
http://twistedmatrix.com/trac/browser/tags/releases/twisted-15.4.0/twisted/words/protocols/irc.py#L3013


replace this line:
self.file.seek(self._resumeOffset)

with:
self.file.seek(-3,2)


which removes the last 3 bytes from the file end, 3 is just a guess.


def connectionMade(self):
        dst = path.abspath(path.join(self.destDir,self.filename))
        exists = path.exists(dst)
        if self.resume and exists:
            print "yes i want to resume and the file is there"
            # I have been told I want to resume, and a file already
            # exists - Here we go
            self.file = open(dst, 'rb+')
            self.file.seek(-3,2)
            self.file.truncate()
            log.msg("Attempting to resume %s - starting from %d bytes" %
                    (self.file, self.file.tell()))
        elif self.resume and not exists:
            raise OSError(errno.ENOENT,
                          "You cannot resume writing to a file "
                          "that does not exist!",
                          dst)
        elif self.overwrite or not exists:
            self.file = open(dst, 'wb')
        else:
            raise OSError(errno.EEXIST,
                          "There's a file in the way.  "
                          "Perhaps that's why you cannot open it.",
                          dst)


_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to