]> git.lizzy.rs Git - cheatdb.git/blobdiff - app/tasks/importtasks.py
Fix unexpected crash on bad Github URL
[cheatdb.git] / app / tasks / importtasks.py
index c3f865750ba106b27acaff834dc0c74ea9706dbb..8c061d0d136d02fbbf58271986568ba0a70eaf80 100644 (file)
@@ -17,7 +17,7 @@
 
 import flask, json, os, git, tempfile, shutil
 from git import GitCommandError
-from flask.ext.sqlalchemy import SQLAlchemy
+from flask_sqlalchemy import SQLAlchemy
 from urllib.error import HTTPError
 import urllib.request
 from urllib.parse import urlparse, quote_plus, urlsplit
@@ -29,6 +29,10 @@ from app.utils import randomString
 
 class GithubURLMaker:
        def __init__(self, url):
+               self.baseUrl = None
+               self.user = None
+               self.repo = None
+
                # Rewrite path
                import re
                m = re.search("^\/([^\/]+)\/([^\/]+)\/?$", url.path)
@@ -348,6 +352,7 @@ def makeVCSReleaseFromGithub(id, branch, release, url):
        release.url          = urlmaker.getCommitDownload(commits[0]["sha"])
        release.task_id     = None
        release.commit_hash = commits[0]["sha"]
+       release.approve(release.package.author)
        print(release.url)
        db.session.commit()
 
@@ -379,6 +384,7 @@ def makeVCSRelease(id, branch):
                        release.url         = "/uploads/" + filename
                        release.task_id     = None
                        release.commit_hash = repo.head.object.hexsha
+                       release.approve(release.package.author)
                        print(release.url)
                        db.session.commit()