[pbs-devel] [RFC v2 pxar 09/36] encoder: add payload advance capability

Fabian Grünbichler f.gruenbichler at proxmox.com
Mon Mar 11 14:22:06 CET 2024


On March 5, 2024 10:26 am, Christian Ebner wrote:
> Allows to advance the payload writer position by a given size.
> This is used to update the encoders payload input position when
> injecting reused chunks for files with unchanged metadata.
> 
> Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
> ---
> changes since version 1:
> - no changes
> 
>  src/encoder/aio.rs  | 5 +++++
>  src/encoder/mod.rs  | 6 ++++++
>  src/encoder/sync.rs | 5 +++++
>  3 files changed, 16 insertions(+)
> 
> diff --git a/src/encoder/aio.rs b/src/encoder/aio.rs
> index 97fee25..dc926b8 100644
> --- a/src/encoder/aio.rs
> +++ b/src/encoder/aio.rs
> @@ -117,6 +117,11 @@ impl<'a, T: SeqWrite + 'a> Encoder<'a, T> {
>              .await
>      }
>  
> +    /// Add size to payload stream
> +    pub fn advance(&mut self, size: u64) -> io::Result<()> {
> +        self.inner.advance(size)
> +    }
> +
>      /// Create a new subdirectory. Note that the subdirectory has to be finished by calling the
>      /// `finish()` method, otherwise the entire archive will be in an error state.
>      pub async fn create_directory<P: AsRef<Path>>(
> diff --git a/src/encoder/mod.rs b/src/encoder/mod.rs
> index 6cbd56f..c90a526 100644
> --- a/src/encoder/mod.rs
> +++ b/src/encoder/mod.rs
> @@ -519,6 +519,12 @@ impl<'a, T: SeqWrite + 'a> EncoderImpl<'a, T> {
>          Ok(())
>      }
>  
> +    /// Add size to payload stream
> +    pub fn advance(&mut self, size: u64) -> io::Result<()> {
> +        self.state_mut()?.payload_write_position += size;

so isn't this in fact a PayloadOffset then (like it is returned as in
the corresponding getter)? and isn't the size then actually another
offset as well? would maybe make it easier to avoid "holding it wrong"
(i.e., passing in some other u64), or at least, force to wrap it in
PayloadOffset which hopefully entails double-checking that that makes
sense ;)

> +        Ok(())
> +    }
> +
>      /// Return a file offset usable with `add_hardlink`.
>      pub async fn add_symlink(
>          &mut self,
> diff --git a/src/encoder/sync.rs b/src/encoder/sync.rs
> index cf10bce..c462c93 100644
> --- a/src/encoder/sync.rs
> +++ b/src/encoder/sync.rs
> @@ -121,6 +121,11 @@ impl<'a, T: SeqWrite + 'a> Encoder<'a, T> {
>          ))
>      }
>  
> +    /// Add size to payload stream
> +    pub fn advance(&mut self, size: u64) -> io::Result<()> {
> +        self.inner.advance(size)
> +    }

same here

> +
>      /// Create a new subdirectory. Note that the subdirectory has to be finished by calling the
>      /// `finish()` method, otherwise the entire archive will be in an error state.
>      pub fn create_directory<P: AsRef<Path>>(
> -- 
> 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