mirror of
https://git.yoctoproject.org/poky
synced 2026-05-07 16:59:22 +00:00
bitbake: toaster: models.py do not use transactions
This is the counterpart patch of do not use transactions if the database autocommits fix on toasterui, applied to models.py [YOCTO #7402] (Bitbake rev: 48d0d510816346073f135bb86fb7904fdb50bb27) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
7d9dd125f1
commit
e248a503ba
@@ -724,7 +724,7 @@ class LayerIndexLayerSource(LayerSource):
|
||||
"""
|
||||
assert self.apiurl is not None
|
||||
from django.db import IntegrityError
|
||||
from django.db import transaction
|
||||
from django.db import transaction, connection
|
||||
|
||||
import httplib, urlparse, json
|
||||
import os
|
||||
@@ -789,7 +789,8 @@ class LayerIndexLayerSource(LayerSource):
|
||||
|
||||
# update layers
|
||||
layers_info = _get_json_response(apilinks['layerItems'])
|
||||
transaction.set_autocommit(False)
|
||||
if not connection.features.autocommits_when_autocommit_is_off:
|
||||
transaction.set_autocommit(False)
|
||||
for li in layers_info:
|
||||
l, created = Layer.objects.get_or_create(layer_source = self, name = li['name'])
|
||||
l.up_id = li['id']
|
||||
@@ -801,7 +802,8 @@ class LayerIndexLayerSource(LayerSource):
|
||||
l.summary = li['summary']
|
||||
l.description = li['description']
|
||||
l.save()
|
||||
transaction.set_autocommit(True)
|
||||
if not connection.features.autocommits_when_autocommit_is_off:
|
||||
transaction.set_autocommit(True)
|
||||
|
||||
# update layerbranches/layer_versions
|
||||
print "Fetching layer information"
|
||||
@@ -809,7 +811,8 @@ class LayerIndexLayerSource(LayerSource):
|
||||
+ "?filter=branch:%s" % "OR".join(map(lambda x: str(x.up_id), [i for i in Branch.objects.filter(layer_source = self) if i.up_id is not None] ))
|
||||
)
|
||||
|
||||
transaction.set_autocommit(False)
|
||||
if not connection.features.autocommits_when_autocommit_is_off:
|
||||
transaction.set_autocommit(False)
|
||||
for lbi in layerbranches_info:
|
||||
lv, created = Layer_Version.objects.get_or_create(layer_source = self,
|
||||
up_id = lbi['id'],
|
||||
@@ -822,12 +825,14 @@ class LayerIndexLayerSource(LayerSource):
|
||||
lv.commit = lbi['actual_branch']
|
||||
lv.dirpath = lbi['vcs_subdir']
|
||||
lv.save()
|
||||
transaction.set_autocommit(True)
|
||||
if not connection.features.autocommits_when_autocommit_is_off:
|
||||
transaction.set_autocommit(True)
|
||||
|
||||
# update layer dependencies
|
||||
layerdependencies_info = _get_json_response(apilinks['layerDependencies'])
|
||||
dependlist = {}
|
||||
transaction.set_autocommit(False)
|
||||
if not connection.features.autocommits_when_autocommit_is_off:
|
||||
transaction.set_autocommit(False)
|
||||
for ldi in layerdependencies_info:
|
||||
try:
|
||||
lv = Layer_Version.objects.get(layer_source = self, up_id = ldi['layerbranch'])
|
||||
@@ -846,7 +851,8 @@ class LayerIndexLayerSource(LayerSource):
|
||||
LayerVersionDependency.objects.filter(layer_version = lv).delete()
|
||||
for lvd in dependlist[lv]:
|
||||
LayerVersionDependency.objects.get_or_create(layer_version = lv, depends_on = lvd)
|
||||
transaction.set_autocommit(True)
|
||||
if not connection.features.autocommits_when_autocommit_is_off:
|
||||
transaction.set_autocommit(True)
|
||||
|
||||
|
||||
# update machines
|
||||
@@ -854,21 +860,26 @@ class LayerIndexLayerSource(LayerSource):
|
||||
machines_info = _get_json_response(apilinks['machines']
|
||||
+ "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self)))
|
||||
)
|
||||
transaction.set_autocommit(False)
|
||||
|
||||
if not connection.features.autocommits_when_autocommit_is_off:
|
||||
transaction.set_autocommit(False)
|
||||
for mi in machines_info:
|
||||
mo, created = Machine.objects.get_or_create(layer_source = self, up_id = mi['id'], layer_version = Layer_Version.objects.get(layer_source = self, up_id = mi['layerbranch']))
|
||||
mo.up_date = mi['updated']
|
||||
mo.name = mi['name']
|
||||
mo.description = mi['description']
|
||||
mo.save()
|
||||
transaction.set_autocommit(True)
|
||||
|
||||
if not connection.features.autocommits_when_autocommit_is_off:
|
||||
transaction.set_autocommit(True)
|
||||
|
||||
# update recipes; paginate by layer version / layer branch
|
||||
print "Fetching target information"
|
||||
recipes_info = _get_json_response(apilinks['recipes']
|
||||
+ "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self)))
|
||||
)
|
||||
transaction.set_autocommit(False)
|
||||
if not connection.features.autocommits_when_autocommit_is_off:
|
||||
transaction.set_autocommit(False)
|
||||
for ri in recipes_info:
|
||||
try:
|
||||
ro, created = Recipe.objects.get_or_create(layer_source = self, up_id = ri['id'], layer_version = Layer_Version.objects.get(layer_source = self, up_id = ri['layerbranch']))
|
||||
@@ -886,7 +897,8 @@ class LayerIndexLayerSource(LayerSource):
|
||||
except:
|
||||
#print "Duplicate Recipe, ignoring: ", vars(ro)
|
||||
pass
|
||||
transaction.set_autocommit(True)
|
||||
if not connection.features.autocommits_when_autocommit_is_off:
|
||||
transaction.set_autocommit(True)
|
||||
pass
|
||||
|
||||
class BitbakeVersion(models.Model):
|
||||
|
||||
Reference in New Issue
Block a user