mirror of
				https://github.com/f-droid/fdroidserver.git
				synced 2025-11-04 06:30:27 +03:00 
			
		
		
		
	do not delete yml metadata when raumel not installed
This commit is contained in:
		
							parent
							
								
									0885303672
								
							
						
					
					
						commit
						8e5232076f
					
				
					 2 changed files with 14 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -27,6 +27,7 @@ import logging
 | 
			
		|||
import textwrap
 | 
			
		||||
import io
 | 
			
		||||
import yaml
 | 
			
		||||
import importlib
 | 
			
		||||
from collections import OrderedDict
 | 
			
		||||
 | 
			
		||||
import fdroidserver.common
 | 
			
		||||
| 
						 | 
				
			
			@ -1584,11 +1585,15 @@ def write_metadata(metadatapath, app):
 | 
			
		|||
        warn_or_exception(_('Cannot write "{path}", not an accepted format, use: {formats}')
 | 
			
		||||
                          .format(path=metadatapath, formats=', '.join(accepted)))
 | 
			
		||||
 | 
			
		||||
    with open(metadatapath, 'w') as mf:
 | 
			
		||||
        if ext == 'txt':
 | 
			
		||||
    if ext == 'txt':
 | 
			
		||||
        with open(metadatapath, 'w') as mf:
 | 
			
		||||
            return write_txt(mf, app)
 | 
			
		||||
        elif ext == 'yml':
 | 
			
		||||
            return write_yaml(mf, app)
 | 
			
		||||
    elif ext == 'yml':
 | 
			
		||||
        if importlib.util.find_spec('ruamel.yaml'):
 | 
			
		||||
            with open(metadatapath, 'w') as mf:
 | 
			
		||||
                return write_yaml(mf, app)
 | 
			
		||||
        else:
 | 
			
		||||
            raise FDroidException('ruamel.yaml not installed, can not write metadata.')
 | 
			
		||||
 | 
			
		||||
    warn_or_exception(_('Unknown metadata format: %s') % metadatapath)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -110,8 +110,8 @@ class RewriteMetaTest(unittest.TestCase):
 | 
			
		|||
            with open('metadata/a.txt', 'w') as f:
 | 
			
		||||
                f.write('Auto Name:a')
 | 
			
		||||
 | 
			
		||||
            def boom(mf, app):
 | 
			
		||||
                raise FDroidException()
 | 
			
		||||
            def boom(*args):
 | 
			
		||||
                raise FDroidException(' '.join((str(x) for x in args)))
 | 
			
		||||
 | 
			
		||||
            with mock.patch('fdroidserver.metadata.write_yaml', boom):
 | 
			
		||||
                with self.assertRaises(FDroidException):
 | 
			
		||||
| 
						 | 
				
			
			@ -128,10 +128,10 @@ class RewriteMetaTest(unittest.TestCase):
 | 
			
		|||
            with open('metadata/a.yml', 'w') as f:
 | 
			
		||||
                f.write('AutoName: a')
 | 
			
		||||
 | 
			
		||||
            def boom(mf, app):
 | 
			
		||||
                raise FDroidException()
 | 
			
		||||
            def boom(*args):
 | 
			
		||||
                raise FDroidException(' '.join((str(x) for x in args)))
 | 
			
		||||
 | 
			
		||||
            with mock.patch('fdroidserver.metadata.write_yaml', boom):
 | 
			
		||||
            with mock.patch('importlib.util.find_spec', boom):
 | 
			
		||||
                with self.assertRaises(FDroidException):
 | 
			
		||||
                    rewritemeta.main()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue