Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ho-229 committed Apr 25, 2024
1 parent ea941bd commit efa5679
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
10 changes: 4 additions & 6 deletions examples/sftp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,10 @@ impl SyncFilter for Filter {
})
.collect::<Vec<_>>();

ticket
.pass_with_placeholder(
(!placeholders.is_empty()).then_some(&*placeholders),
placeholders.len() as _,
)
.unwrap();
match placeholders.is_empty() {
true => ticket.pass().unwrap(),
false => ticket.pass_with_placeholder(&*placeholders).unwrap(),
};
}

fn closed(&self, request: Request, info: info::Closed) {
Expand Down
16 changes: 12 additions & 4 deletions src/filter/ticket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,23 @@ impl FetchPlaceholders {
}
}

/// Returns the empty list of placeholders.
pub fn pass<'a>(&self) -> core::Result<Vec<core::Result<Usn>>> {
command::CreatePlaceholders {
placeholders: None,
total: 0,
}
.execute(self.connection_key, self.transfer_key)
}

/// Returns the list of placeholders.
pub fn pass_with_placeholder<'a>(
&self,
placeholders: impl Into<Option<&'a [PlaceholderFile<'a>]>>,
total: u64,
placeholders: &'a [PlaceholderFile<'a>],
) -> core::Result<Vec<core::Result<Usn>>> {
command::CreatePlaceholders {
placeholders: placeholders.into(),
total,
placeholders: Some(placeholders),
total: placeholders.len() as _,
}
.execute(self.connection_key, self.transfer_key)
}
Expand Down

0 comments on commit efa5679

Please sign in to comment.