def _get_SSLP_by_ptr(self, msg_ptr, verifier=None, from_=False): if verifier is None: verifier = self._verify_ptr_checksums tries = [] length = None for from_start, length in self._possible_message_locations(msg_ptr): # We duplicate the file descriptor here, in case other threads # are accessing the same mailbox and moving it around, or in # case we have multiple PartialFile objects in flight at once. tries.append(str(from_start)) try: start = from_start stop = from_start + length fd = self._get_fd() if not from_: fd.seek(start) length -= len(fd.readline()) start = fd.tell() pf = mailbox._PartialFile(fd, start, stop) if verifier(msg_ptr, from_start, pf): return (from_start, start, length, pf) except IOError: pass err = '%s: %s %s@%s' % (_('Message not found'), msg_ptr, length, '/'.join(tries)) raise IOError(err)
def get_file_by_ptr(self, msg_ptr): parts = msg_ptr[MBX_ID_LEN:].split(':') start = int(parts[0], 36) length = int(parts[1], 36) # Make sure we can actually read the message cs1k = self.get_msg_cs1k(start, length) if len(parts) > 2 and cs1k != parts[2][:4]: raise IOError('Message not found') return mailbox._PartialFile(self._file, start, start+length)
def get_file_by_ptr(self, msg_ptr): parts, start, length = self._parse_ptr(msg_ptr) # Make sure we can actually read the message cs80b = self.get_msg_cs80b(start, length) if len(parts) > 2: cs1k = self.get_msg_cs1k(start, length) cs = parts[2][:4] if (cs1k != cs and cs80b != cs): raise IOError(_('Message not found')) # We duplicate the file descriptor here, in case other threads are # accessing the same mailbox and moving it around, or in case we have # multiple PartialFile objects in flight at once. return mailbox._PartialFile(self._get_fd(), start, start + length)
def get_file_by_ptr(self, msg_ptr): parts = msg_ptr[MBX_ID_LEN:].split(':') start = int(parts[0], 36) length = int(parts[1], 36) # Make sure we can actually read the message cs80b = self.get_msg_cs80b(start, length) if len(parts) > 2: cs1k = self.get_msg_cs1k(start, length) cs = parts[2][:4] if (cs1k != cs and cs80b != cs): raise IOError(_('Message not found')) # We duplicate the file descriptor here, in case other threads are # accessing the same mailbox and moving it around, or in case we have # multiple PartialFile objects in flight at once. return mailbox._PartialFile(self._get_fd(), start, start + length)
def get_file_by_ptr(self, msg_ptr): parts = msg_ptr[MBX_ID_LEN:].split(":") start = int(parts[0], 36) length = int(parts[1], 36) # Make sure we can actually read the message cs80b = self.get_msg_cs80b(start, length) if len(parts) > 2: cs1k = self.get_msg_cs1k(start, length) cs = parts[2][:4] if cs1k != cs and cs80b != cs: raise IOError(_("Message not found")) # We duplicate the file descriptor here, in case other threads are # accessing the same mailbox and moving it around, or in case we have # multiple PartialFile objects in flight at once. return mailbox._PartialFile(self._get_fd(), start, start + length)
def get_file_by_ptr(self, msg_ptr): start, length = msg_ptr[3:].split(':') start = int(start, 36) length = int(length, 36) return mailbox._PartialFile(self._file, start, start+length)