checkupdates: don't fail when we can't init submodules

Later revisions might have removed the submodules so we want to keep
going when there are no submodules present.
We still abort when there is an error initializing submodules.

Fixes fdroid/fdroidserver#231
This commit is contained in:
Marcus Hoffmann 2017-12-04 15:10:21 +01:00
parent 2dcb19d392
commit db0a97e8e7
3 changed files with 23 additions and 7 deletions

View file

@ -33,7 +33,7 @@ import copy
from . import _ from . import _
from . import common from . import common
from . import metadata from . import metadata
from .exception import VCSException, FDroidException, MetaDataException from .exception import VCSException, NoSubmodulesException, FDroidException, MetaDataException
# Check for a new version by looking at a document retrieved via HTTP. # Check for a new version by looking at a document retrieved via HTTP.
@ -110,8 +110,7 @@ def check_tags(app, pattern):
last_build = app.get_last_build() last_build = app.get_last_build()
if last_build.submodules: try_init_submodules(app, last_build, vcs)
vcs.initsubmodules()
hpak = None hpak = None
htag = None htag = None
@ -207,8 +206,7 @@ def check_repomanifest(app, branch=None):
if len(app.builds) > 0: if len(app.builds) > 0:
last_build = app.builds[-1] last_build = app.builds[-1]
if last_build.submodules: try_init_submodules(app, last_build, vcs)
vcs.initsubmodules()
hpak = None hpak = None
hver = None hver = None
@ -300,6 +298,19 @@ def check_gplay(app):
return (version.strip(), None) return (version.strip(), None)
def try_init_submodules(app, last_build, vcs):
"""Try to init submodules if the last build entry used them.
They might have been removed from the app's repo in the meantime,
so if we can't find any submodules we continue with the updates check.
If there is any other error in initializing them then we stop the check.
"""
if last_build.submodules:
try:
vcs.initsubmodules()
except NoSubmodulesException:
logging.info("No submodules present for {}".format(app.Name))
# Return all directories under startdir that contain any of the manifest # Return all directories under startdir that contain any of the manifest
# files, and thus are probably an Android project. # files, and thus are probably an Android project.
def dirs_with_manifest(startdir): def dirs_with_manifest(startdir):

View file

@ -53,7 +53,8 @@ from distutils.util import strtobool
import fdroidserver.metadata import fdroidserver.metadata
from fdroidserver import _ from fdroidserver import _
from fdroidserver.exception import FDroidException, VCSException, BuildException, VerificationException from fdroidserver.exception import FDroidException, VCSException, NoSubmodulesException,\
BuildException, VerificationException
from .asynchronousfilereader import AsynchronousFileReader from .asynchronousfilereader import AsynchronousFileReader
@ -883,7 +884,7 @@ class vcs_git(vcs):
self.checkrepo() self.checkrepo()
submfile = os.path.join(self.local, '.gitmodules') submfile = os.path.join(self.local, '.gitmodules')
if not os.path.isfile(submfile): if not os.path.isfile(submfile):
raise VCSException(_("No git submodules available")) raise NoSubmodulesException(_("No git submodules available"))
# fix submodules not accessible without an account and public key auth # fix submodules not accessible without an account and public key auth
with open(submfile, 'r') as f: with open(submfile, 'r') as f:

View file

@ -39,6 +39,10 @@ class VCSException(FDroidException):
pass pass
class NoSubmodulesException(VCSException):
pass
class BuildException(FDroidException): class BuildException(FDroidException):
pass pass