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:
Eric Callahan 2022-02-17 15:50:41 -05:00
parent 11e299558d
commit f3cd177a02
1 changed files with 4 additions and 0 deletions

View File

@ -380,6 +380,10 @@ class MoonrakerDatabase:
dest_keys: List[str]
) -> None:
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:
for source, dest in zip(source_keys, dest_keys):
val = txn.pop(source.encode())