database: move_batch() fix
Raise an exception if the key lengths for the source and destination keys do not match. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
11e299558d
commit
f3cd177a02
|
@ -380,6 +380,10 @@ class MoonrakerDatabase:
|
||||||
dest_keys: List[str]
|
dest_keys: List[str]
|
||||||
) -> None:
|
) -> None:
|
||||||
db = self._get_db(namespace)
|
db = self._get_db(namespace)
|
||||||
|
if len(source_keys) != len(dest_keys):
|
||||||
|
raise self.server.error(
|
||||||
|
"Source key list and destination key list must "
|
||||||
|
"be of the same length")
|
||||||
with self.lmdb_env.begin(write=True, db=db) as txn:
|
with self.lmdb_env.begin(write=True, db=db) as txn:
|
||||||
for source, dest in zip(source_keys, dest_keys):
|
for source, dest in zip(source_keys, dest_keys):
|
||||||
val = txn.pop(source.encode())
|
val = txn.pop(source.encode())
|
||||||
|
|
Loading…
Reference in New Issue