Skip to content

Commit 1b9b203

Browse files
authored
fix: Don't read and check targetNumIDs file on v7 import (#17)
Apparently old management does not remove entries in targetNumIDs when a target is unmapped. So targets and targetNumIDs might have different length, which would fail the check on the import process. Since targetNumIDs is not used at all for the import, it can as well just be ignored.
1 parent de63b45 commit 1b9b203

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

mgmtd/src/db/import_v7.rs

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,8 @@ pub fn import_v7(tx: &rusqlite::Transaction, base_path: &Path) -> Result<()> {
3636

3737
// Storage
3838
storage_nodes(tx, &base_path.join("storage.nodes")).context("storage.nodes")?;
39-
storage_targets(
40-
tx,
41-
&base_path.join("targets"),
42-
&base_path.join("targetNumIDs"),
43-
)
44-
.context("storage targets (target + targetNumIDs)")?;
39+
storage_targets(tx, &base_path.join("targets"))
40+
.context("storage targets (target + targetNumIDs)")?;
4541
buddy_groups(
4642
tx,
4743
&base_path.join("storagebuddygroups"),
@@ -267,23 +263,14 @@ fn buddy_groups(tx: &Transaction, f: &Path, nt: NodeTypeServer) -> Result<()> {
267263
}
268264

269265
/// Imports storage targets
270-
fn storage_targets(
271-
tx: &Transaction,
272-
targets_path: &Path,
273-
target_num_ids_path: &Path,
274-
) -> Result<()> {
266+
fn storage_targets(tx: &Transaction, targets_path: &Path) -> Result<()> {
275267
let targets = std::fs::read_to_string(targets_path)?;
276-
let target_num_ids = std::fs::read_to_string(target_num_ids_path)?;
277268

278-
if targets.lines().count() != target_num_ids.lines().count() {
279-
bail!("line count mismatch between {targets_path:?} and {target_num_ids_path:?}");
280-
}
281-
282-
for l in targets.lines().zip(target_num_ids.lines()) {
283-
let (target, node) =
284-
l.0.trim()
285-
.split_once('=')
286-
.ok_or_else(|| anyhow!("invalid line '{}'", l.0))?;
269+
for l in targets.lines() {
270+
let (target, node) = l
271+
.trim()
272+
.split_once('=')
273+
.ok_or_else(|| anyhow!("invalid line '{}'", l))?;
287274

288275
let node_id = NodeId::from_str_radix(node.trim(), 16)?;
289276
let target_id = TargetId::from_str_radix(target.trim(), 16)?;

0 commit comments

Comments
 (0)