示例#1
0
文件: song.py 项目: bspeice/Melodia
	def _grab_file_info(self):
		"Populate file-based metadata about this song."
		import os
		#Overload the hash function with whatever Melodia as a whole is using
		from Melodia.melodia_settings import HASH_FUNCTION as hash
		
		file_handle = open(self._get_full_url, 'rb')
		
		self.file_hash = hash(file_handle.read())
		self.file_size = os.stat(self._get_full_url).st_size
示例#2
0
文件: song.py 项目: bspeice/Melodia
	def _file_not_changed(self):
		"Make sure the hash for this file is valid - return True if it has not changed."
		#Overload the hash function with whatever Melodia as a whole is using
		from Melodia.melodia_settings import HASH_FUNCTION as hash

		#Check if there's a hash entry - if there is, the song may not have changed,
		#and we can go ahead and return
		if self.file_hash != None:
			song_file = open(self._get_full_url, 'rb')
			current_file_hash = hash(song_file.read())

			if current_file_hash == self.file_hash:
				#The song data hasn't changed at all, we don't need to do anything
				return True

		return False