Skip to content

Commit

Permalink
chore: 软件下载源添加meta字段
Browse files Browse the repository at this point in the history
  • Loading branch information
Cnotech committed Dec 15, 2024
1 parent 7cb4515 commit c84fb5b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/types/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::{package::GlobalPackage, permissions::Permission};
use serde::{Deserialize, Serialize};
use ts_rs::TS;

#[derive(Serialize, Deserialize, Clone, Debug, TS)]
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug, TS)]
#[ts(export)]
pub struct MetaResult {
pub temp_dir: Option<String>,
Expand Down
14 changes: 13 additions & 1 deletion src/types/mirror.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use anyhow::Result;
use regex::Regex;
use serde::{Deserialize, Deserializer, Serialize, Serializer};

use super::{extended_semver::ExSemVer, mixed_fs::MixedFS, verifiable::Verifiable};
use super::{
extended_semver::ExSemVer, meta::MetaResult, mixed_fs::MixedFS, verifiable::Verifiable,
};

lazy_static! {
static ref FLAGS_RE: Regex = Regex::new(r"\.([A-Z]+)\.nep$").unwrap();
Expand Down Expand Up @@ -150,6 +152,7 @@ impl MirrorPkgSoftware {
size: 94245376,
timestamp: 1704554724,
integrity: None,
meta: None,
}],
}],
);
Expand All @@ -163,6 +166,7 @@ impl MirrorPkgSoftware {
size: 94245376,
timestamp: 1704554724,
integrity: None,
meta: None,
}],
}],
);
Expand All @@ -176,6 +180,7 @@ impl MirrorPkgSoftware {
size: 133763072,
timestamp: 1704554608,
integrity: None,
meta: None,
}],
}],
);
Expand All @@ -189,6 +194,7 @@ impl MirrorPkgSoftware {
size: 192179712,
timestamp: 1704554110,
integrity: None,
meta: None,
}],
}],
);
Expand Down Expand Up @@ -218,6 +224,7 @@ pub struct MirrorPkgSoftwareRelease {
pub size: u64,
pub timestamp: u64,
pub integrity: Option<String>,
pub meta: Option<MetaResult>,
}

impl MirrorPkgSoftwareRelease {
Expand Down Expand Up @@ -254,6 +261,7 @@ fn test_get_flags() {
size: 114514,
timestamp: 114514,
integrity: None,
meta: None,
};
assert_eq!(r.get_flags(), None);

Expand All @@ -263,6 +271,7 @@ fn test_get_flags() {
size: 114514,
timestamp: 114514,
integrity: None,
meta: None,
};
assert_eq!(r.get_flags(), Some("P".to_string()));

Expand All @@ -272,6 +281,7 @@ fn test_get_flags() {
size: 114514,
timestamp: 114514,
integrity: None,
meta: None,
};
assert_eq!(r.get_flags(), Some("EI".to_string()));

Expand All @@ -281,6 +291,7 @@ fn test_get_flags() {
size: 114514,
timestamp: 114514,
integrity: None,
meta: None,
};
assert_eq!(r.get_flags(), Some("EI".to_string()));

Expand All @@ -290,6 +301,7 @@ fn test_get_flags() {
size: 114514,
timestamp: 114514,
integrity: None,
meta: None,
};
assert_eq!(r.get_flags(), None);
}
Expand Down
10 changes: 10 additions & 0 deletions src/utils/mirror.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,20 +299,23 @@ fn test_filter_release() {
size: 94245376,
timestamp: 1704554724,
integrity: None,
meta: None,
},
MirrorPkgSoftwareRelease {
file_name: "VSCode_1.86.1.0_Cno.nep".to_string(),
version: ExSemVer::parse(&"1.86.1.0".to_string()).unwrap(),
size: 94245376,
timestamp: 1704554724,
integrity: None,
meta: None,
},
MirrorPkgSoftwareRelease {
file_name: "VSCode_1.85.2.0_Cno.nep".to_string(),
version: ExSemVer::parse(&"1.85.2.0".to_string()).unwrap(),
size: 94245376,
timestamp: 1704554724,
integrity: None,
meta: None,
},
];
let res = filter_release(arr, None, false).unwrap();
Expand All @@ -326,20 +329,23 @@ fn test_filter_release() {
size: 133763072,
timestamp: 1704554608,
integrity: None,
meta: None,
},
MirrorPkgSoftwareRelease {
file_name: "Chrome_121.0.6099.200_Cno.nep".to_string(),
version: ExSemVer::parse(&"121.0.6099.200".to_string()).unwrap(),
size: 133763072,
timestamp: 1704554608,
integrity: None,
meta: None,
},
MirrorPkgSoftwareRelease {
file_name: "Chrome_122.0.6099.200_Cno.nep".to_string(),
version: ExSemVer::parse(&"122.0.6099.200".to_string()).unwrap(),
size: 133763072,
timestamp: 1704554608,
integrity: None,
meta: None,
},
];
let res = filter_release(arr, Some(VersionReq::parse("121").unwrap()), false).unwrap();
Expand All @@ -363,27 +369,31 @@ fn test_filter_release_with_flags() {
size: 94245376,
timestamp: 1704554724,
integrity: None,
meta: None,
},
MirrorPkgSoftwareRelease {
file_name: "Firefox_127.0.0.1_Cno.IE.nep".to_string(),
version: ExSemVer::from_str("127.0.0.1").unwrap(),
size: 94245376,
timestamp: 1704554724,
integrity: None,
meta: None,
},
MirrorPkgSoftwareRelease {
file_name: "Firefox_127.0.0.1_Cno.P.nep".to_string(),
version: ExSemVer::from_str("127.0.0.1").unwrap(),
size: 94245376,
timestamp: 1704554724,
integrity: None,
meta: None,
},
MirrorPkgSoftwareRelease {
file_name: "Firefox_127.0.0.1_Cno.PE.nep".to_string(),
version: ExSemVer::from_str("127.0.0.1").unwrap(),
size: 94245376,
timestamp: 1704554724,
integrity: None,
meta: None,
},
];

Expand Down

0 comments on commit c84fb5b

Please sign in to comment.