summaryrefslogtreecommitdiffstats
path: root/src/source
AgeCommit message (Collapse)Author
2021-11-19Update Copyright string to 2020-2022Matthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-09-29Do not include source hash in source file nameMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-06-08Fix: Do not fail if directory existsMatthias Beyer
butido should not fail if the source cache directory already exists (which is the case when downloading two source files for one package). Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Tested-by: Matthias Beyer <matthias.beyer@atos.net>
2021-04-08Optimize: Remove helperMatthias Beyer
Because we can just use the actual interface function here. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-04-08Remove helper Source::exists()Matthias Beyer
It is easier for the caller (because more visible what happens) to call `Source::path().exists()`. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-02-02Add more error context informationMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-02-02Make source verification completely asyncMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-01-25Reimplement hash verification using streamingMatthias Beyer
This patch re-implements hashing using streams and buffered readers instead of reading a full file to RAM before hashing it. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-01-19Fix: Hash verification not asyncMatthias Beyer
Because we continuously get blocking filesystem operations when the implementation of the verification is async, simply remove the asyncness here now. This does not decrease performance (yet), because the function is called concurrently with other calls anyways. It blocks the tokio worker thread tho, thus maximum parallelism might be = number of cores. :-( Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-01-18Run `cargo fmt`Matthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-01-15Add feature to mark a source entry as manual downloadMatthias Beyer
This patch adds a feature where a source entry in a package can be marked for manual download. This gives us the ability to mask downloads which are hidden behind cruel JavaScript bullshit bloat where a `curl` cannot access the remote file. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2021-01-13Revert "Reimplement hash verification"Matthias Beyer
This reverts commit c3fc1281142ec10414197a31070cc45930a859e3 and commit 18b256e040881ac674463913b2a7e290125ea738. The problem here is that we introduced "ring" to our dependencies, which has a unappropriate license (ISC and openssl thing). We should not depend on such a library, because it may conflict with our own EPL 2.0 (IANAL). Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-01-13Add LICENSE file and license headersMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2021-01-12Move hashing itself into blocking taskMatthias Beyer
This patch, as a followup to 18b256e040881ac674463913b2a7e290125ea738 ("Reimplement hash verification") moves the hashing itself into the blocking closure, so that we get maximum parallelism here. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-01-12Reimplement hash verificationMatthias Beyer
This patch re-implements hashing using the "ring" crypto library and implementing a streaming hashing with it. This way, we stream the file to the hasher rather than reading the full file to memory. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-01-12Fix: Spawn filesystem task on a blocking tokio threadMatthias Beyer
This patch changes the (possibly heavy) File reading from disk to be executed on a blocking tokio thread. This way, we ensure we do not block until the `read()` operation is finished and can continue executing async tasks on the runtime. Because IO might be expensive (think of a 5GB file that is read to memory), this is a good optimization. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-01-11Fix: Do not use tokio in SourceEntry::verify_hash()Christoph Prokop
Because tokio seems to block forever here when "read()"ing the file to memory, we use the `std::fs` API here. This blocks, but is called async in tokio anyways, so we at least get _some_ parallelization. It is at least "a bit" parallelized, as this only allows parallelization up to N `read()`s, where N is the number of tokio runtime threads, which is the number of cores of the machine this is called on. The `tokio::fs` API is a wrapper around `std::fs` anyways, right now. So until tokio can work with async OS API calls (io_uring anyone?), this is not worse as `tokio::fs`. Signed-off-by: Christoph Prokop <christoph.prokop@atos.net> Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Tested-by: Christoph Prokop <christoph.prokop@atos.net> Tested-by: Matthias Beyer <matthias.beyer@atos.net>
2020-12-09Add some more trace outputMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-09Change implementation to return Ok(()) on successMatthias Beyer
This changes the source file hash verification mechanism to return an Ok(()) on success and an Err(_) on failure. Returning a bool seems to be the right way, but it is not because if the verification fails, we print the error message anyways, so there is no point in having a bool around. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-09Fix: Create directory for source entry before creating fileMatthias Beyer
Because the source is downloaded to a directory instead of a flat file in the source cache root, we should ensure this directory exists. We do not, though, create the source cache root directory, but only check whether it is there. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-07Make sources namedMatthias Beyer
This patch changes the sources to be named. This is required for nice interpolation when layering pkg.toml files. Before this, we had to make sure that the `[[sources]]` array element was on the right position. For example, consider two files: /pkg.toml /package/pkg.toml in the first: [[sources]] url = "some/thing" in the second: [[sources] hash.type = "sha1" hash.value = "asdf..." When merged: [[sources] url = "some/thing" hash.type = "sha1" hash.value = "asdf..." but because the _position_ was responsible for merging these elements, adding a new source file _before_ the existing on in /pkg.toml would yield the /package/pkg.toml incomplete when merged onto /pkg.toml, thus resulting in an error. With named source entries, this is less likely. The source file name includes the source name as well, of course. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-07Remove SourceEntry::open() (unused)Matthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-03Allow multiple sources per packageMatthias Beyer
This patch implements multiple (unnamed) sources per package. This means that a package can have an array of sources. What was adapted to allow multiple sources per package: * Downloads are made in parallel now * The cache structure was changed to /<package>-<version>/<hash>.source * The UI was changed to contain the full `Package` struct (as JSON object) in a UI format string Tests were adapted. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-03Cleanup importsMatthias Beyer
This patch cleans the imports, removes the unused ones and moves imports, wherever possible, to the outer scope. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-11-14Add debug output, error context informationMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-11-11Make SourceCache impl Clone, DebugMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-11-11Add subcommand "source download"Matthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-11-11Add SourceEntry::remove_file() helperMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-11-11Add SourceEntry::url()Matthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-11-11Add source cache typesMatthias Beyer
This adds a module for source cache handling. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>