[entropy.db] make importRepository() atomic
This commit is contained in:
@@ -4699,13 +4699,16 @@ class EntropyRepository(EntropyRepositoryBase):
|
||||
@todo: remove /usr/bin/sqlite3 dependency
|
||||
"""
|
||||
dbfile = os.path.realpath(dbfile)
|
||||
tmp_dbfile = dbfile + ".import_repository"
|
||||
dumpfile = os.path.realpath(dumpfile)
|
||||
if not entropy.tools.is_valid_path_string(dbfile):
|
||||
raise AttributeError("dbfile value is invalid")
|
||||
if not entropy.tools.is_valid_path_string(dumpfile):
|
||||
raise AttributeError("dumpfile value is invalid")
|
||||
sqlite3_exec = "/usr/bin/sqlite3 \"%s\" < \"%s\"" % (dbfile, dumpfile,)
|
||||
sqlite3_exec = "/usr/bin/sqlite3 \"%s\" < \"%s\"" % (tmp_dbfile,
|
||||
dumpfile,)
|
||||
retcode = subprocess.call(sqlite3_exec, shell = True)
|
||||
os.rename(tmp_dbfile, dbfile)
|
||||
return retcode
|
||||
|
||||
def exportRepository(self, dumpfile, gentle_with_tables = True,
|
||||
|
||||
Reference in New Issue
Block a user