Use same transactional try-except-else as YCDL.
This commit is contained in:
		
							parent
							
								
									7609f20dd0
								
							
						
					
					
						commit
						03ae8325c9
					
				
					 1 changed files with 11 additions and 3 deletions
				
			
		|  | @ -284,9 +284,17 @@ def upgrade_all(data_directory): | ||||||
|         print('Upgrading from %d to %d.' % (current_version, version_number)) |         print('Upgrading from %d to %d.' % (current_version, version_number)) | ||||||
|         upgrade_function = 'upgrade_%d_to_%d' % (current_version, version_number) |         upgrade_function = 'upgrade_%d_to_%d' % (current_version, version_number) | ||||||
|         upgrade_function = eval(upgrade_function) |         upgrade_function = eval(upgrade_function) | ||||||
|  | 
 | ||||||
|  |         try: | ||||||
|  |             photodb.sql.execute('BEGIN') | ||||||
|             upgrade_function(photodb) |             upgrade_function(photodb) | ||||||
|  |         except Exception as exc: | ||||||
|  |             photodb.rollback() | ||||||
|  |             raise | ||||||
|  |         else: | ||||||
|             photodb.sql.cursor().execute('PRAGMA user_version = %d' % version_number) |             photodb.sql.cursor().execute('PRAGMA user_version = %d' % version_number) | ||||||
|             photodb.commit() |             photodb.commit() | ||||||
|  | 
 | ||||||
|         current_version = version_number |         current_version = version_number | ||||||
|     print('Upgrades finished.') |     print('Upgrades finished.') | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue