* txn protect virtual install too
This commit is contained in:
@@ -409,18 +409,18 @@ def __is_virtual_upgrade(metadata):
|
|||||||
|
|
||||||
return upgrade
|
return upgrade
|
||||||
|
|
||||||
def virtual_install(metadata, files):
|
def virtual_install(metadata, files, txn):
|
||||||
"""Recreate the package info for rebuilddb command"""
|
"""Recreate the package info for rebuilddb command"""
|
||||||
pkg = metadata.package
|
pkg = metadata.package
|
||||||
|
|
||||||
# normally this can't be true. Just for backward compatibility
|
# normally this can't be true. Just for backward compatibility
|
||||||
# TODO: for speed only ctx.installdb.install exception can be
|
# TODO: for speed only ctx.installdb.install exception can be
|
||||||
# handled but this is much cleaner
|
# handled but this is much cleaner
|
||||||
if ctx.installdb.is_installed(pkg.name):
|
if ctx.installdb.is_installed(pkg.name, txn):
|
||||||
if __is_virtual_upgrade(metadata):
|
if __is_virtual_upgrade(metadata):
|
||||||
ctx.installdb.remove(pkg.name)
|
ctx.installdb.remove(pkg.name, txn)
|
||||||
packagedb.remove_package(pkg.name)
|
packagedb.remove_package(pkg.name, txn)
|
||||||
ctx.filesdb.remove_files(ctx.installdb.files(pkg.name))
|
ctx.filesdb.remove_files(ctx.installdb.files(pkg.name), txn)
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -431,13 +431,14 @@ def virtual_install(metadata, files):
|
|||||||
metadata.package.version,
|
metadata.package.version,
|
||||||
metadata.package.release,
|
metadata.package.release,
|
||||||
metadata.package.build,
|
metadata.package.build,
|
||||||
metadata.package.distribution)
|
metadata.package.distribution,
|
||||||
|
txn)
|
||||||
|
|
||||||
# filesdb
|
# filesdb
|
||||||
ctx.filesdb.add_files(metadata.package.name, files)
|
ctx.filesdb.add_files(metadata.package.name, files, txn)
|
||||||
|
|
||||||
# installed packages
|
# installed packages
|
||||||
packagedb.inst_packagedb.add_package(pkginfo)
|
packagedb.inst_packagedb.add_package(pkginfo, txn)
|
||||||
|
|
||||||
def resurrect_package(package_fn):
|
def resurrect_package(package_fn):
|
||||||
"""Resurrect the package in the PiSi databases"""
|
"""Resurrect the package in the PiSi databases"""
|
||||||
@@ -479,6 +480,8 @@ def resurrect_package(package_fn):
|
|||||||
raise Error, _("Invalid %s") % ctx.const.files_xml
|
raise Error, _("Invalid %s") % ctx.const.files_xml
|
||||||
|
|
||||||
import pisi.atomicoperations
|
import pisi.atomicoperations
|
||||||
pisi.atomicoperations.virtual_install(metadata, files)
|
def f(txn):
|
||||||
|
pisi.atomicoperations.virtual_install(metadata, files, txn)
|
||||||
|
ctx.txn_proc(f)
|
||||||
if not passed:
|
if not passed:
|
||||||
ctx.ui.info(_('OK.'))
|
ctx.ui.info(_('OK.'))
|
||||||
|
|||||||
@@ -666,7 +666,7 @@ If package specs are given, they should be the names of package dirs under /var/
|
|||||||
os.unlink(pisi.util.join_path(ctx.config.db_dir(), db))
|
os.unlink(pisi.util.join_path(ctx.config.db_dir(), db))
|
||||||
self.init(database=True)
|
self.init(database=True)
|
||||||
self.rebuild_db()
|
self.rebuild_db()
|
||||||
verfn = join_path(pisi.context.config.db_dir(), 'dbversion')
|
verfn = util.join_path(pisi.context.config.db_dir(), 'dbversion')
|
||||||
verfile = file(verfn, 'w')
|
verfile = file(verfn, 'w')
|
||||||
verfile.write(pisi.__dbversion__)
|
verfile.write(pisi.__dbversion__)
|
||||||
verfile.close()
|
verfile.close()
|
||||||
|
|||||||
+2
-1
@@ -42,8 +42,9 @@ initialized = False
|
|||||||
# """ Register a UI implementation"""
|
# """ Register a UI implementation"""
|
||||||
# ui = _impl
|
# ui = _impl
|
||||||
|
|
||||||
|
import bsddb3.db as db
|
||||||
|
|
||||||
def txn_proc(proc, txn):
|
def txn_proc(proc, txn = None):
|
||||||
# can be used to txn protect a method automatically
|
# can be used to txn protect a method automatically
|
||||||
assert dbenv
|
assert dbenv
|
||||||
if not txn:
|
if not txn:
|
||||||
|
|||||||
+1
-1
@@ -59,7 +59,7 @@ class File:
|
|||||||
|
|
||||||
def __init__(self, uri, mode, transfer_dir = "/tmp"):
|
def __init__(self, uri, mode, transfer_dir = "/tmp"):
|
||||||
"it is pointless to open a file without a URI and a mode"
|
"it is pointless to open a file without a URI and a mode"
|
||||||
uri = make_uri(uri)
|
uri = File.make_uri(uri)
|
||||||
if mode==File.read or mode==File.write:
|
if mode==File.read or mode==File.write:
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ from pisi import archive
|
|||||||
from pisi import sourcearchive
|
from pisi import sourcearchive
|
||||||
from pisi import fetcher
|
from pisi import fetcher
|
||||||
from pisi import util
|
from pisi import util
|
||||||
#from pisi.build import BuildContext
|
|
||||||
from pisi.specfile import SpecFile
|
from pisi.specfile import SpecFile
|
||||||
from pisi import uri
|
from pisi import uri
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user