mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 06:22:24 +01:00
Fix postReleaseCheckUpdate running twice on release creation
This commit is contained in:
parent
afb699f8d3
commit
6ebab36877
@ -26,7 +26,7 @@ from wtforms.validators import InputRequired, Length
|
||||
|
||||
from app.models import *
|
||||
from app.tasks.forumtasks import importTopicList, checkAllForumAccounts
|
||||
from app.tasks.importtasks import importRepoScreenshot, checkZipRelease, updateMetaFromRelease, importForeignDownloads
|
||||
from app.tasks.importtasks import importRepoScreenshot, checkZipRelease, importForeignDownloads
|
||||
from app.utils import rank_required, addAuditLog, addNotification
|
||||
from . import bp
|
||||
|
||||
@ -64,7 +64,7 @@ def admin_page():
|
||||
release = package.releases.first()
|
||||
if release:
|
||||
zippath = release.url.replace("/uploads/", app.config["UPLOAD_DIR"])
|
||||
tasks.append(updateMetaFromRelease.s(release.id, zippath))
|
||||
tasks.append(checkZipRelease.s(release.id, zippath))
|
||||
|
||||
result = group(tasks).apply_async()
|
||||
|
||||
|
@ -30,7 +30,7 @@ from wtforms.validators import *
|
||||
|
||||
from app.querybuilder import QueryBuilder
|
||||
from app.rediscache import has_key, set_key
|
||||
from app.tasks.importtasks import importRepoScreenshot, updateMetaFromRelease
|
||||
from app.tasks.importtasks import importRepoScreenshot, checkZipRelease
|
||||
from app.utils import *
|
||||
from . import bp
|
||||
|
||||
@ -545,6 +545,6 @@ def update_from_release(package):
|
||||
|
||||
task_id = uuid()
|
||||
zippath = release.url.replace("/uploads/", app.config["UPLOAD_DIR"])
|
||||
updateMetaFromRelease.apply_async((release.id, zippath), task_id=task_id)
|
||||
checkZipRelease.apply_async((release.id, zippath), task_id=task_id)
|
||||
|
||||
return redirect(url_for("tasks.check", id=task_id, r=package.getEditURL()))
|
||||
|
@ -24,7 +24,7 @@ from wtforms.ext.sqlalchemy.fields import QuerySelectField
|
||||
from wtforms.validators import *
|
||||
|
||||
from app.rediscache import has_key, set_key, make_download_key
|
||||
from app.tasks.importtasks import makeVCSRelease, checkZipRelease, updateMetaFromRelease
|
||||
from app.tasks.importtasks import makeVCSRelease, checkZipRelease
|
||||
from app.utils import *
|
||||
from . import bp
|
||||
|
||||
@ -108,7 +108,6 @@ def create_release(package):
|
||||
db.session.commit()
|
||||
|
||||
checkZipRelease.apply_async((rel.id, uploadedPath), task_id=rel.task_id)
|
||||
updateMetaFromRelease.delay(rel.id, uploadedPath)
|
||||
|
||||
msg = "Release {} created".format(rel.title)
|
||||
addNotification(package.maintainers, current_user, NotificationType.PACKAGE_EDIT, msg, rel.getEditURL(), package)
|
||||
|
@ -169,25 +169,6 @@ def postReleaseCheckUpdate(self, release, path):
|
||||
raise TaskError(str(err))
|
||||
|
||||
|
||||
@celery.task(bind=True)
|
||||
def updateMetaFromRelease(self, id, path):
|
||||
release = PackageRelease.query.get(id)
|
||||
if release is None:
|
||||
raise TaskError("No such release!")
|
||||
elif release.package is None:
|
||||
raise TaskError("No package attached to release")
|
||||
|
||||
print("updateMetaFromRelease: {} for {}/{}" \
|
||||
.format(id, release.package.author.display_name, release.package.name))
|
||||
|
||||
with get_temp_dir() as temp:
|
||||
with ZipFile(path, 'r') as zip_ref:
|
||||
zip_ref.extractall(temp)
|
||||
|
||||
postReleaseCheckUpdate(self, release, temp)
|
||||
db.session.commit()
|
||||
|
||||
|
||||
@celery.task(bind=True)
|
||||
def checkZipRelease(self, id, path):
|
||||
release = PackageRelease.query.get(id)
|
||||
@ -232,8 +213,6 @@ def makeVCSRelease(self, id, branch):
|
||||
release.approve(release.package.author)
|
||||
db.session.commit()
|
||||
|
||||
updateMetaFromRelease.delay(release.id, destPath)
|
||||
|
||||
return release.url
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user