5
0
mirror of git://git.proxmox.com/git/pxar.git synced 2024-12-22 21:33:50 +03:00
Commit Graph

256 Commits

Author SHA1 Message Date
Christian Ebner
d51db63953 encoder/format: finish payload stream with marker
Mark the end of the optional payload stream, this makes sure that at
least some bytes are written to the stream (as empty archives are not
allowed by the proxmox backup server) and possible injected chunks
must be consumed.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-06-05 09:24:22 +02:00
Christian Ebner
7e8af7b6e0 encoder: add payload advance capability
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@proxmox.com>
2024-06-05 09:24:22 +02:00
Christian Ebner
2c1daa75fa encoder: add payload position capability
Allows to read the current payload offset from the dedicated payload
input stream. This is required to get the current offset for calculation
of forced boundaries in the proxmox-backup-client, when injecting reused
payload chunks into the payload stream.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-06-05 09:24:22 +02:00
Christian Ebner
15fbb28319 encoder: add payload reference capability
Allows to encode regular files with a payload reference within a
separate payload archive rather than encoding the payload within the
regular archive.

Following the PXAR_PAYLOAD_REF marked header, the payload offset and
size are encoded.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-06-05 09:24:22 +02:00
Christian Ebner
1c30a6547b decoder: set payload input range when decoding via accessor
When accessing the file contents via the sequential file restore
the range of the payload contents cannot be inferred a-priori but need
to be calculated based on the payload references encountered during
decoding.

Extending the `SeqRead` trait by the method `update_range` allows to
set the range in the payload reader instance by implementing the
method for `SeqReadAtAdapter`, thereby setting the correct content
range to be accessed.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-06-05 09:24:22 +02:00
Christian Ebner
3ee98e1072 decoder/accessor: allow for split input stream variant
When a pxar archive was encoded using the split stream output
variant, access to the payload of regular files has to be redirected
to the corresponding dedicated input.

Allow to pass the split input variant to the decoder and accessor
instances to handle the split streams accordingly and decode split
stream archives.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-06-05 09:24:22 +02:00
Christian Ebner
99d4f646be encoder: allow split output writer for archive creation
During regular pxar archive encoding, the payload of regular files is
written as part of the archive.

This patch introduces functionality to instead attach a writer variant
with a split payload writer instance to redirect the payload to a
different output.
The separation of data and metadata streams allows for efficient
reuse of payload data by referencing the payload writer byte offset,
without having to reencode it.

Whenever the payload of regular files is redirected to a dedicated
output writer, encode a payload reference header followed by the
required data to locate the data, instead of adding the regular payload
header followed by the encoded payload to the archive.

This is in preparation for reusing payload chunks for unchanged files
of backups created via the proxmox-backup-client.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-06-05 09:24:22 +02:00
Christian Ebner
2a7b789bbd decoder: add method to read payload references
This is in preparation for reading payloads from a dedicated payload
input stream.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-05-23 14:39:11 +02:00
Christian Ebner
d3447d0149 format/examples: add header type PXAR_PAYLOAD_REF
Introduces the header type `PXAR_PAYLOAD_REF` to mark regular file
entry payloads, not encoded within the regular pxar archive but
rather redirected to a dedicated payload output writer.
It therefore substitutes the `PXAR_PAYLOAD` header type for these
entries.

The header marks the start and size for a `PayloadRef` typed object
in the archive, storing the offset to the payload header offset in the
payload stream of the dedicated payload output as well as the payload
size.

The `PayloadRef` provides the means to store, serialize and
deserialize the entry.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-05-23 14:39:11 +02:00
Christian Ebner
48431e5e38 encoder: move to stack based state tracking
In preparation for the proxmox-backup-client look-ahead caching,
where a passing around of different encoder instances with internal
references is not feasible.

Instead of creating a new encoder instance for each directory level
and keeping references to the parent state, use an internal stack.
Adds additional helper functions to solve borrow issues, when both
the state and writers have to be accessed by a mutable reference.

This is a breaking change in the pxar library API.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-05-23 14:39:11 +02:00
Christian Ebner
a79ae33c14 lib: add type for input/output variant differentiation
Introduce an enum which stores 2 different possible variants of
inputs or outputs to be passed to encoder and decoder/accessor
instances, depending whether to read/write a fully self contained
pxar archive or whether to split off the payload stream into a
separate input/output.

Co-authored-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-05-23 11:26:23 +02:00
Christian Ebner
e5b9854989 decoder: factor out skip part from skip_entry
Make the skip part reusable for a different input.

In preparation for skipping payload paddings in a separated input.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-05-23 11:26:08 +02:00
Fabian Grünbichler
675ecff32f encoder: fix some more typos/phrasing
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-04-03 11:11:40 +02:00
Christian Ebner
237917b741 encoder: fix two typos in comments
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-04-03 11:09:26 +02:00
Christian Ebner
f5be8e5c6d format/examples: Fix typo in PXAR_PAYLOAD description
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-02-28 19:09:31 +01:00
Wolfgang Bumiller
fab6470854 doc fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-08-04 13:11:03 +02:00
Max Carrara
4355e8e619 decoder: aio: Make TokioReader public
This exposes `decoder::aio::TokioReader<T>` in a similar manner to
`decoder::sync::StandardReader<T>`, which is necessary if one wants
to remain generic over `T: tokio::io::AsyncRead`, e.g.:

> struct FooDecoder<T: tokio::io::AsyncRead> {
>    decoder: aio::Decoder<aio::TokioReader<T>>,
> }

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
2023-08-04 13:09:09 +02:00
Fabian Grünbichler
de472e826d d/changelog: fix typo
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-07-31 15:45:17 +02:00
Christian Ebner
00d36bf97b format: Document source of format const values
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2023-05-17 11:27:08 +02:00
Wolfgang Bumiller
6ad046f9f9 drop custom poll_fn, require rust 1.64
this was added to std in 1.64

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-01-13 13:37:43 +01:00
Fabian Grünbichler
375865b729 update d/control
after debcargo update

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-01-09 13:33:47 +01:00
Wolfgang Bumiller
729281cd93 bump upload target
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-10-27 15:31:33 +02:00
Wolfgang Bumiller
a84425dbc3 bump d/control
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-10-27 15:29:14 +02:00
Wolfgang Bumiller
29cbeed3e1 bump version to 0.10.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-10-27 15:28:22 +02:00
Wolfgang Bumiller
165dcc33a2 clippy fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-10-27 15:25:50 +02:00
Lukas Wagner
6ec9e99994 derive PartialEq trait for Metadata and related structs
This change is needed in order to compare a file's metadata
in the coming proxmox-backup-debug diff tool.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2022-10-27 15:24:24 +02:00
Wolfgang Bumiller
a6e6873f70 fix fifo and socket entry kinds in accessor
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-10-27 15:18:20 +02:00
Wolfgang Bumiller
85f5a177ef test socket/fifo entry kinds in accessor
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-10-27 15:18:20 +02:00
Wolfgang Bumiller
6f3f889e98 update buildbot.yml for tokio 1.18
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-07-28 14:54:24 +02:00
Wolfgang Bumiller
ddc08ebb8b don't hold temp buffer mutex across await point
the type system guarantees that this can only be accessed by
a single mutable instance, but it's still a bad idea

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-07-28 14:36:46 +02:00
Wolfgang Bumiller
a50514a920 trivial clippy fixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-07-28 14:36:43 +02:00
Wolfgang Bumiller
3a83f493f5 drop imports already in 2021 prelude
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-12-01 14:14:47 +01:00
Wolfgang Bumiller
c40ababaac another clippy fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-12-01 14:10:33 +01:00
Wolfgang Bumiller
81d500297d clippy fixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-12-01 14:09:10 +01:00
Wolfgang Bumiller
149f88f3c9 upgrade to edition 2021
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-12-01 13:54:52 +01:00
Wolfgang Bumiller
ceb4a54674 more clippy fixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-11-12 13:53:47 +01:00
Wolfgang Bumiller
609e3a633f use #![deny(unsafe_op_in_unsafe_fn)]
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-11-12 13:52:17 +01:00
Wolfgang Bumiller
04eccc8e53 buildbot.yml: remove tokio+fs dep
it's provided by the tokio main package and we have an old
real package around which causes buildbot issues

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-05 09:31:01 +02:00
Wolfgang Bumiller
2d8f513a21 add back .buildbot.yml
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-04 15:29:46 +02:00
Wolfgang Bumiller
8184367000 bump d/control
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-04 15:07:54 +02:00
Wolfgang Bumiller
1a2a5570b1 fix deprecated use of std::u64 modules
MAX values in these modules are replaced by associated
constants in the integer types

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-04 15:00:44 +02:00
Wolfgang Bumiller
e5a2495ed3 add more code documentation
all but the `format` module are now #![deny(missing_docs)]

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-05-17 14:09:19 +02:00
Wolfgang Bumiller
5d4e59c52c make the ReadAtImpl enum variants private
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-05-17 14:09:19 +02:00
Wolfgang Bumiller
71194b54e4 ditch anyhow crate in examples/tests
mostly to shutup our current buildbot tests

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-05-17 11:46:53 +02:00
Wolfgang Bumiller
d4a04d53c9 some clippy fixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-05-07 11:57:28 +02:00
Wolfgang Bumiller
b203d38bcd bump version to 0.10.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-03-31 13:56:22 +02:00
Wolfgang Bumiller
07265b3e37 rustfmt
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-03-31 13:54:18 +02:00
Stefan Reiter
8a9c71c035 decoder/aio: add contents() and content_size() calls
Returns a decoder::Contents without a wrapper type, since in this case
we don't want to hide the SeqRead implementation (as done in
decoder::sync). For conviencience also implement AsyncRead if "tokio-io"
is enabled.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2021-03-31 13:52:24 +02:00
Wolfgang Bumiller
eae6dc06af rustfmt
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-03-31 13:52:09 +02:00
Wolfgang Bumiller
e827b69a60 encoder: only flush owned outputs in 'finish'
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-03-31 13:51:46 +02:00