X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Fdescriptor_topics.py;h=24f47a9bf9494cec265bde6fba2e5899df227952;hp=9113b0cf7ecce4aadb21fa002052dd4e96c707ea;hb=cddb07d092fdcf72ce2c87cd801b93732e64d3a9;hpb=19b9752a7f43e1fcf1bdfd0040c1e8edfe9e6f3a diff --git a/osm_nbi/descriptor_topics.py b/osm_nbi/descriptor_topics.py index 9113b0c..24f47a9 100644 --- a/osm_nbi/descriptor_topics.py +++ b/osm_nbi/descriptor_topics.py @@ -377,10 +377,15 @@ class DescriptorTopic(BaseTopic): # no yes -> error # onefile yes no -> zip # X yes -> text - - if accept_text and (not storage.get('pkg-dir') or path == "$DESCRIPTOR"): + contain_many_files = False + if storage.get('pkg-dir'): + # check if there are more than one file in the package, ignoring checksums.txt. + pkg_files = self.fs.dir_ls((storage['folder'], storage['pkg-dir'])) + if len(pkg_files) >= 3 or (len(pkg_files) == 2 and 'checksums.txt' not in pkg_files): + contain_many_files = True + if accept_text and (not contain_many_files or path == "$DESCRIPTOR"): return self.fs.file_open((storage['folder'], storage['descriptor']), "r"), "text/plain" - elif storage.get('pkg-dir') and not accept_zip: + elif contain_many_files and not accept_zip: raise EngineException("Packages that contains several files need to be retrieved with 'application/zip'" "Accept header", http_code=HTTPStatus.NOT_ACCEPTABLE) else: