mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +00:00 
			
		
		
		
	Move "rebuild_thumbnails" to being a management command
- Does not run every time the server reboots - Has to be called manually - Normally does not need to be run and is a long-running process!
This commit is contained in:
		| @@ -23,29 +23,4 @@ class CompanyConfig(AppConfig): | ||||
|         This function is called whenever the Company app is loaded. | ||||
|         """ | ||||
|  | ||||
|         if canAppAccessDatabase(): | ||||
|             self.generate_company_thumbs() | ||||
|  | ||||
|     def generate_company_thumbs(self): | ||||
|  | ||||
|         from .models import Company | ||||
|  | ||||
|         logger.debug("Checking Company image thumbnails") | ||||
|  | ||||
|         try: | ||||
|             for company in Company.objects.all(): | ||||
|                 if company.image: | ||||
|                     url = company.image.thumbnail.name | ||||
|                     loc = os.path.join(settings.MEDIA_ROOT, url) | ||||
|  | ||||
|                     if not os.path.exists(loc): | ||||
|                         logger.info("InvenTree: Generating thumbnail for Company '{c}'".format(c=company.name)) | ||||
|                         try: | ||||
|                             company.image.render_variations(replace=False) | ||||
|                         except FileNotFoundError: | ||||
|                             logger.warning(f"Image file '{company.image}' missing") | ||||
|                         except UnidentifiedImageError: | ||||
|                             logger.warning(f"Image file '{company.image}' is invalid") | ||||
|         except (OperationalError, ProgrammingError): | ||||
|             # Getting here probably meant the database was in test mode | ||||
|             pass | ||||
|         pass | ||||
|   | ||||
		Reference in New Issue
	
	Block a user