[pbs-devel] [PATCH proxmox-backup] encoder: merge create_file and create_file_do

Fabian Grünbichler f.gruenbichler at proxmox.com
Mon Jul 1 13:22:54 CEST 2024


doesn't apply anymore, if this should still be done, please rebase+resend!

On March 12, 2024 11:09 am, Christian Ebner wrote:
> `create_file` only transforms the path to bytes before calling
> `create_file_do` with it. Since this is the only caller and the latter
> method is private, this can be merged into one method to reduce code.
> 
> Suggested-by: Dietmar Maurer <dietmar at proxmox.com>
> Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
> ---
>  src/encoder/mod.rs | 15 ++-------------
>  1 file changed, 2 insertions(+), 13 deletions(-)
> 
> diff --git a/src/encoder/mod.rs b/src/encoder/mod.rs
> index 0d342ec..21eb78a 100644
> --- a/src/encoder/mod.rs
> +++ b/src/encoder/mod.rs
> @@ -340,25 +340,14 @@ impl<'a, T: SeqWrite + 'a> EncoderImpl<'a, T> {
>          file_name: &Path,
>          file_size: u64,
>      ) -> io::Result<FileImpl<'b, T>>
> -    where
> -        'a: 'b,
> -    {
> -        self.create_file_do(metadata, file_name.as_os_str().as_bytes(), file_size)
> -            .await
> -    }
> -
> -    async fn create_file_do<'b>(
> -        &'b mut self,
> -        metadata: &Metadata,
> -        file_name: &[u8],
> -        file_size: u64,
> -    ) -> io::Result<FileImpl<'b, T>>
>      where
>          'a: 'b,
>      {
>          self.check()?;
>  
>          let file_offset = self.position();
> +        let file_name = file_name.as_os_str().as_bytes();
> +
>          self.start_file_do(Some(metadata), file_name).await?;
>  
>          let header = format::Header::with_content_size(format::PXAR_PAYLOAD, file_size);
> -- 
> 2.39.2
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
> 
> 
> 




More information about the pbs-devel mailing list