def saveDataBuffer(self):
		fileName = utils.getPartialPathName(self.url)
		f = file(fileName, 'wb')
		self.dataBuffer.seek(0, 0)
		f.write(self.dataBuffer.read())
		f.close()
		self.record.numFailures = 0
	def transformEnclosure(self, url, enclosure, host):
		# TODO: don't transform the enclosure if we won't prefetch it (if record.sent)
		# TODO: refactor this with the other transformEnclosure()
		# TODO: Catch value errors on other fields as well
		try:
			length = int(enclosure.getAttribute('length').encode('utf8'))
		except ValueError:
			# Set length to zero and hope that we can use HTTP Content-Length header later.
			length = 0
		channel = getChannel(enclosure)
		title = getTitle(enclosure)
		record = self.feedStore.get(url)
		if not record:
			record = Record(url, length, channel, title)
			self.feedStore[url] = record
		else:
			# Don't reset length based on enclosure value. It may be wrong. (The
			# Content-Length received while prefetching is usually more accurate.)
			if record.length == 0:
				record.length = length
			record.channel = channel
			record.title = title
		record.published = getPubDate(enclosure)
		record.partialPath = utils.getPartialPathName(url)
		record.lastSeen = time.time()
		enclosure.setAttribute('url', utils.getEnclosureURL(url, host))
	def __init__(self, metainfo, config, handler, keepAlive, url, finishTimeout):
		super(TorrentInfo, self).__init__()
		self.metainfo = metainfo
		self.config = config
		self.handler = handler
		self.keepAlive = keepAlive
		self.url = url
		# TODO: look in config['save_in'] for destination path? (only if keep_downloads is set)
		if not os.path.isdir(utils.PARTIALS_DIR):
			os.makedirs(utils.PARTIALS_DIR)
		self.pathName = utils.getPartialPathName(metainfo.name_fs)
		self.finishTimeout = finishTimeout
		self.started = None