1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-07-04 16:30:12 +02:00

make read_metadata only parse files actually used by lint/rewritemeta

Now that the description formatting is removed, there is no need to load
all of the app metadata before operating on a single one.  This change
makes lint and rewritemeta only load the metadata for the apps it is actually
operating on.  Before, it would always load all metadata files.  #845

closes #678
This commit is contained in:
Hans-Christoph Steiner 2020-11-17 16:43:26 +01:00
parent c98b15e72a
commit 129438fd30
3 changed files with 19 additions and 5 deletions

View File

@ -583,7 +583,7 @@ def main():
config = common.read_config(options)
# Get all apps...
allapps = metadata.read_metadata()
allapps = metadata.read_metadata(options.appid)
apps = common.read_app_args(options.appid, allapps, False)
anywarns = check_for_unsupported_metadata_files()

View File

@ -541,7 +541,7 @@ def read_srclibs():
srclibs[srclibname] = parse_yaml_srclib(metadatapath)
def read_metadata(check_vcs=[], refresh=True, sort_by_time=False):
def read_metadata(appids=None, check_vcs=[], refresh=True, sort_by_time=False):
"""Return a list of App instances sorted newest first
This reads all of the metadata files in a 'data' repository, then
@ -563,8 +563,22 @@ def read_metadata(check_vcs=[], refresh=True, sort_by_time=False):
if not os.path.exists(basedir):
os.makedirs(basedir)
metadatafiles = (glob.glob(os.path.join('metadata', '*.yml'))
+ glob.glob('.fdroid.yml'))
if appids:
vercodes = fdroidserver.common.read_pkg_args(appids)
found_invalid = False
metadatafiles = []
for appid in vercodes.keys():
f = os.path.join('metadata', '%s.yml' % appid)
if os.path.exists(f):
metadatafiles.append(f)
else:
found_invalid = True
logging.critical(_("No such package: %s") % appid)
if found_invalid:
raise FDroidException(_("Found invalid appids in arguments"))
else:
metadatafiles = (glob.glob(os.path.join('metadata', '*.yml'))
+ glob.glob('.fdroid.yml'))
if sort_by_time:
entries = ((os.stat(path).st_mtime, path) for path in metadatafiles)

View File

@ -61,7 +61,7 @@ def main():
config = common.read_config(options)
# Get all apps...
allapps = metadata.read_metadata()
allapps = metadata.read_metadata(options.appid)
apps = common.read_app_args(options.appid, allapps, False)
for appid, app in apps.items():