mirror of
				https://github.com/bspeice/Melodia
				synced 2025-10-31 09:20:40 -04:00 
			
		
		
		
	Optimize the filesystem scanning slightly
This commit is contained in:
		| @ -43,7 +43,7 @@ class Archive (models.Model): | |||||||
| 		"Scan the archive's root filesystem and add any new songs without adding metadata, delete songs that exist no more" | 		"Scan the archive's root filesystem and add any new songs without adding metadata, delete songs that exist no more" | ||||||
| 		#This method is implemented since the other scan methods all need to use the same code | 		#This method is implemented since the other scan methods all need to use the same code | ||||||
| 		#DRY FTW | 		#DRY FTW | ||||||
| 		import re, os | 		import re, os, itertools | ||||||
| 		from django.core.exceptions import ObjectDoesNotExist | 		from django.core.exceptions import ObjectDoesNotExist | ||||||
| 		from Melodia.melodia_settings import SUPPORTED_AUDIO_EXTENSIONS | 		from Melodia.melodia_settings import SUPPORTED_AUDIO_EXTENSIONS | ||||||
| 		from Melodia.melodia_settings import HASH_FUNCTION as hash | 		from Melodia.melodia_settings import HASH_FUNCTION as hash | ||||||
| @ -60,10 +60,8 @@ class Archive (models.Model): | |||||||
|  |  | ||||||
| 		#Add new songs | 		#Add new songs | ||||||
| 		for dirname, dirnames, filenames in os.walk(self.root_folder): | 		for dirname, dirnames, filenames in os.walk(self.root_folder): | ||||||
| 			#For each filename | 			#For each filename that is supported | ||||||
| 			for filename in filenames: | 			for filename in itertools.ifilter(lambda filename: re.match(regex, filename), filenames): | ||||||
| 				#If the filename is a supported audio extension |  | ||||||
| 				if re.match(regex, filename): |  | ||||||
| 				#Make sure that `filename` is in the database | 				#Make sure that `filename` is in the database | ||||||
| 				try: | 				try: | ||||||
| 					rel_url = os.path.join(dirname, filename) | 					rel_url = os.path.join(dirname, filename) | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Bradlee Speice
					Bradlee Speice