mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-04 22:40:29 +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 textwrap
|
||||||
import io
|
import io
|
||||||
import yaml
|
import yaml
|
||||||
|
import importlib
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
import fdroidserver.common
|
import fdroidserver.common
|
||||||
|
|
@ -1584,11 +1585,15 @@ def write_metadata(metadatapath, app):
|
||||||
warn_or_exception(_('Cannot write "{path}", not an accepted format, use: {formats}')
|
warn_or_exception(_('Cannot write "{path}", not an accepted format, use: {formats}')
|
||||||
.format(path=metadatapath, formats=', '.join(accepted)))
|
.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)
|
return write_txt(mf, app)
|
||||||
elif ext == 'yml':
|
elif ext == 'yml':
|
||||||
|
if importlib.util.find_spec('ruamel.yaml'):
|
||||||
|
with open(metadatapath, 'w') as mf:
|
||||||
return write_yaml(mf, app)
|
return write_yaml(mf, app)
|
||||||
|
else:
|
||||||
|
raise FDroidException('ruamel.yaml not installed, can not write metadata.')
|
||||||
|
|
||||||
warn_or_exception(_('Unknown metadata format: %s') % metadatapath)
|
warn_or_exception(_('Unknown metadata format: %s') % metadatapath)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,8 +110,8 @@ class RewriteMetaTest(unittest.TestCase):
|
||||||
with open('metadata/a.txt', 'w') as f:
|
with open('metadata/a.txt', 'w') as f:
|
||||||
f.write('Auto Name:a')
|
f.write('Auto Name:a')
|
||||||
|
|
||||||
def boom(mf, app):
|
def boom(*args):
|
||||||
raise FDroidException()
|
raise FDroidException(' '.join((str(x) for x in args)))
|
||||||
|
|
||||||
with mock.patch('fdroidserver.metadata.write_yaml', boom):
|
with mock.patch('fdroidserver.metadata.write_yaml', boom):
|
||||||
with self.assertRaises(FDroidException):
|
with self.assertRaises(FDroidException):
|
||||||
|
|
@ -128,10 +128,10 @@ class RewriteMetaTest(unittest.TestCase):
|
||||||
with open('metadata/a.yml', 'w') as f:
|
with open('metadata/a.yml', 'w') as f:
|
||||||
f.write('AutoName: a')
|
f.write('AutoName: a')
|
||||||
|
|
||||||
def boom(mf, app):
|
def boom(*args):
|
||||||
raise FDroidException()
|
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):
|
with self.assertRaises(FDroidException):
|
||||||
rewritemeta.main()
|
rewritemeta.main()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue