This repository was archived by the owner on May 2, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: persistance system #61
Open
saenai255
wants to merge
19
commits into
oxidation
Choose a base branch
from
feat/persistance-system
base: oxidation
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
d2c0e26
add: persistance system
saenai255 94b29dc
add: caching system
saenai255 945b3ea
deps: remove time 0.1 dependency
saenai255 817e873
docs: improve style
saenai255 7668b2a
chore: impl `From` for filters
saenai255 53ae5de
Update src/store/fs.rs
saenai255 acd0afe
Update src/store/fs.rs
saenai255 af11403
Update src/store/fs.rs
saenai255 43ebc11
Update src/store/fs.rs
saenai255 d825b99
Update src/store/fs.rs
saenai255 47cba1d
Update src/store/fs.rs
saenai255 6c690f4
Update src/store/fs.rs
saenai255 d454cfb
Update src/store/fs.rs
saenai255 0ef067f
ref(store): ref so Base trait is not used
saenai255 09838a6
Merge branch 'feat/persistance-system' of github.com:pacstall/libpacs…
saenai255 6cb663b
add: integration
saenai255 7cf0b38
chore: use `ensure!` and `report!`
saenai255 6de8656
add: store examples
saenai255 8eb4a20
add: rest of PKGBUILD spec
saenai255 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,5 @@ | |
| )] | ||
| #![allow(clippy::must_use_candidate)] | ||
| pub mod config; | ||
| pub mod model; | ||
| pub mod store; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| //! Provides structs to handle Pacstall's data models. | ||
|
|
||
| mod pacbuild; | ||
| mod repository; | ||
|
|
||
| pub use crate::model::pacbuild::*; | ||
| pub use crate::model::repository::{default_repository, Repository}; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| //! | ||
|
|
||
| use chrono::NaiveDateTime as DateTime; | ||
| use serde_derive::{Deserialize, Serialize}; | ||
|
|
||
| /// Representation of the PACBUILD file. | ||
| #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] | ||
| pub struct PacBuild { | ||
| /// PacBuild unique name per [`Repository`](crate::model::Repository). | ||
| pub name: PackageId, | ||
|
|
||
| /// Last time it was changed. | ||
| pub last_updated: DateTime, | ||
|
|
||
| /// [`Repository`](crate::model::Repository) url. | ||
| pub repository: URL, | ||
|
|
||
| /// Maintainer name and possibly email. | ||
| /// | ||
| /// # Example | ||
| /// `Paul Cosma <[email protected]>` | ||
| pub maintainer: String, | ||
|
|
||
| /// Canonical package name. Usually the `name` without the type extension. | ||
| /// | ||
| /// # Example | ||
| /// - `PacBuild { name: "discord-deb", package_name: "discord" }` | ||
| pub package_name: String, | ||
|
|
||
| /// Short package description. | ||
| pub description: String, | ||
|
|
||
| /// Official homepage [URL]. | ||
| pub homepage: URL, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shoud be optional |
||
|
|
||
| /// Latest version fetched from Repology. | ||
| pub repology_version: Version, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why should we store the repology version? |
||
|
|
||
| /// Repology filter. | ||
| /// | ||
| /// # Example | ||
| /// **TBA** | ||
| pub repology: String, | ||
|
Comment on lines
+43
to
+47
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be a |
||
|
|
||
| /// Installation state. | ||
| pub install_state: InstallState, | ||
|
|
||
| /// Runtime dependencies. | ||
| pub dependencies: Vec<PackageId>, | ||
|
|
||
| /// Optional dependencies. | ||
| pub optional_dependencies: Vec<PackageId>, | ||
|
|
||
| /// SPDX License. | ||
| pub license: String, | ||
|
|
||
| /// Download [URL]. | ||
| pub url: URL, | ||
|
|
||
| /// [`PacBuild`] type, deduced from the name suffix. | ||
| pub kind: Kind, | ||
| } | ||
|
|
||
| /// Represents a `SemVer` version. | ||
| /// # Examples | ||
saenai255 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /// | ||
| /// ``` | ||
| /// use libpacstall::model::Version; | ||
| /// | ||
| /// let ver: Version = "1.0.0".into(); | ||
| /// ``` | ||
| pub type Version = String; | ||
|
|
||
| /// Represents a [`PacBuild`] or Apt package name. | ||
| /// # Examples | ||
| /// | ||
| /// ``` | ||
| /// use libpacstall::model::PackageId; | ||
| /// | ||
| /// let identifier: PackageId = "discord-deb".into(); | ||
| /// ``` | ||
| pub type PackageId = String; | ||
| /// Represents an URL | ||
| /// # Examples | ||
| /// | ||
| /// ``` | ||
| /// use libpacstall::model::URL; | ||
| /// | ||
| /// let url: URL = "https://example.com".into(); | ||
| /// ``` | ||
| pub type URL = String; | ||
| /// Represents a file checksum | ||
| /// # Examples | ||
| /// | ||
| /// ``` | ||
| /// use libpacstall::model::Hash; | ||
| /// | ||
| /// let hash: Hash = "b5c9710f33204498efb64cf8257cd9b19e9d3e6b".into(); | ||
| /// ``` | ||
| pub type Hash = String; | ||
|
|
||
| /// Represents the install state of a package. | ||
| /// # Examples | ||
| /// | ||
| /// ``` | ||
| /// use chrono::NaiveDate; | ||
| /// use libpacstall::model::InstallState; | ||
| /// | ||
| /// let installed_directly = InstallState::Direct( | ||
| /// NaiveDate::from_ymd(2016, 7, 8).and_hms(9, 10, 11), | ||
| /// "0.9.2".into(), | ||
| /// ); | ||
| /// ``` | ||
| #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] | ||
| pub enum InstallState { | ||
| /// Package is installed directly, meaning the user wanted it. | ||
| Direct(DateTime, Version), | ||
|
|
||
| /// Package is installed as a dependency. | ||
| Indirect(DateTime, Version), | ||
|
|
||
| /// Package is not installed. | ||
| None, | ||
| } | ||
|
|
||
| impl InstallState { | ||
| /// Returns `true` if the package is installed otherwise `false`. | ||
| pub fn is_installed(&self) -> bool { !matches!(self, Self::None) } | ||
| } | ||
|
|
||
| /// Represents the type of the package. Usually deduced by the [PacBuild#name] | ||
| /// suffix. | ||
| /// | ||
| /// # Examples | ||
| /// | ||
| /// ``` | ||
| /// use libpacstall::model::Kind; | ||
| /// | ||
| /// let git_release = Kind::GitRelease; | ||
| /// ``` | ||
| #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] | ||
| pub enum Kind { | ||
| /// [`PacBuild`] will install an `AppImage`. | ||
| AppImage(Hash), | ||
|
|
||
| /// [`PacBuild`] will install a prebuilt, usually `tar.gz`, package. | ||
| Binary(Hash), | ||
|
|
||
| /// [`PacBuild`] will install an existing `.deb` file. | ||
| DebFile(Hash), | ||
|
|
||
| /// [`PacBuild`] will install the source of a given Git branch. | ||
| GitBranch, | ||
|
|
||
| /// [`PacBuild`] will install the source of a given Git release. | ||
| GitRelease, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| use serde_derive::{Deserialize, Serialize}; | ||
|
|
||
| /// Representation of a Pacstall repository. | ||
| /// | ||
| /// Defaults to the official repository. | ||
| #[derive(Deserialize, Debug, Eq, PartialEq, Serialize, Clone)] | ||
| #[serde(deny_unknown_fields)] | ||
| pub struct Repository { | ||
| /// The name of the repository. | ||
| pub name: String, | ||
| /// URL of the repository. | ||
| /// | ||
| /// Note that the URL **isn't verified** during extraction! | ||
| pub url: String, | ||
| /// Preference of the repository. | ||
| /// | ||
| /// Specifies which repository to look into first during certain operations | ||
| /// like installing a package. If the package isn't present in the first | ||
| /// preferred repository, then the second preferred repository is looked | ||
| /// into. | ||
| pub preference: u32, | ||
| } | ||
|
|
||
| #[allow(clippy::module_name_repetitions)] | ||
| pub fn default_repository() -> Vec<Repository> { vec![Repository::default()] } | ||
|
|
||
| impl Default for Repository { | ||
| fn default() -> Self { | ||
| Self { | ||
| name: "official".into(), | ||
| url: "https://github.com/pacstall/pacstall-programs".into(), | ||
| preference: 1, | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.