Skip to content

Commit 357f0a2

Browse files
committed
Add is_index_pad in put context
1 parent d4778ff commit 357f0a2

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

mutant-lib/src/ops/put/mod.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ struct Context {
2828
public: bool,
2929
/// Optional preserved index pad for public key updates
3030
preserved_index_pad: Option<PadInfo>,
31+
/// Flag to indicate if this context is for an index pad
32+
is_index_pad: bool,
3133
}
3234

3335
/// Update a key with new content, preserving the public index pad if applicable.
@@ -81,6 +83,7 @@ async fn update(
8183
data: content.clone(),
8284
public,
8385
preserved_index_pad: None,
86+
is_index_pad: false,
8487
};
8588

8689
// Write the data pads
@@ -97,7 +100,7 @@ async fn update(
97100
old_pad.size = index_pad.size;
98101
old_pad.status = PadStatus::Free;
99102
old_pad.last_known_counter += 1;
100-
103+
101104
old_pad
102105
});
103106

@@ -114,6 +117,7 @@ async fn update(
114117
data: index_data_bytes,
115118
public,
116119
preserved_index_pad: preserved_index_pad.clone(),
120+
is_index_pad: true, // This is an index pad
117121
};
118122

119123
// Write the index pad
@@ -250,6 +254,7 @@ async fn resume(
250254
chunk_ranges: Arc::new(chunk_ranges),
251255
public,
252256
preserved_index_pad: None,
257+
is_index_pad: false, // This is for data pads, not the index pad
253258
};
254259

255260
write_pipeline(context, pads.clone(), no_verify, put_callback.clone()).await?;
@@ -268,6 +273,7 @@ async fn resume(
268273
data: index_data_bytes,
269274
public, // Keep public flag
270275
preserved_index_pad: None, // No preserved index pad for normal operations
276+
is_index_pad: true, // This is an index pad
271277
};
272278

273279
// Call write_pipeline again for the single index pad
@@ -310,6 +316,7 @@ async fn first_store(
310316
data: data_bytes.clone(),
311317
public,
312318
preserved_index_pad: None,
319+
is_index_pad: false, // This is for data pads, not the index pad
313320
};
314321

315322
write_pipeline(context, pads.clone(), no_verify, put_callback.clone()).await?;
@@ -328,6 +335,7 @@ async fn first_store(
328335
data: index_data_bytes,
329336
public, // Keep public flag
330337
preserved_index_pad: None, // No preserved index pad for normal operations
338+
is_index_pad: true, // This is an index pad
331339
};
332340

333341
// Call write_pipeline again for the single index pad
@@ -392,11 +400,8 @@ impl AsyncTask<PadInfo, PutTaskContext, Object<crate::network::client::ClientMan
392400
};
393401

394402
if should_put {
395-
// Determine if this is an index pad for a public upload
396-
// For public uploads, the index pad is the one with chunk_index 0 and only one chunk range
397-
let is_index_pad = is_public
398-
&& pad_state.chunk_index == 0
399-
&& self.context.base_context.chunk_ranges.len() == 1;
403+
// Use the is_index_pad flag from the context to determine if this is an index pad
404+
let is_index_pad = is_public && self.context.base_context.is_index_pad;
400405

401406
// Check if we have a preserved index pad that we should use instead
402407
if is_index_pad && self.context.base_context.preserved_index_pad.is_some() {

0 commit comments

Comments
 (0)