You've already forked AstralRinth
forked from didirus/AstralRinth
Fix hashes not showing (#496)
* Fix hashes not showing * Run prepare + fmt
This commit is contained in:
@@ -642,11 +642,11 @@ impl Version {
|
|||||||
.map(|x| VersionStatus::from_str(&x)),
|
.map(|x| VersionStatus::from_str(&x)),
|
||||||
},
|
},
|
||||||
files: {
|
files: {
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize, Debug)]
|
||||||
struct Hash {
|
struct Hash {
|
||||||
pub file_id: FileId,
|
pub file_id: FileId,
|
||||||
pub algorithm: String,
|
pub algorithm: String,
|
||||||
pub hash: Vec<u8>,
|
pub hash: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
@@ -795,7 +795,7 @@ impl Version {
|
|||||||
struct Hash {
|
struct Hash {
|
||||||
pub file_id: FileId,
|
pub file_id: FileId,
|
||||||
pub algorithm: String,
|
pub algorithm: String,
|
||||||
pub hash: Vec<u8>,
|
pub hash: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
@@ -907,7 +907,7 @@ pub struct QueryFile {
|
|||||||
pub id: FileId,
|
pub id: FileId,
|
||||||
pub url: String,
|
pub url: String,
|
||||||
pub filename: String,
|
pub filename: String,
|
||||||
pub hashes: HashMap<String, Vec<u8>>,
|
pub hashes: HashMap<String, String>,
|
||||||
pub primary: bool,
|
pub primary: bool,
|
||||||
pub size: u32,
|
pub size: u32,
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-15
@@ -452,21 +452,12 @@ impl From<QueryVersion> for Version {
|
|||||||
files: data
|
files: data
|
||||||
.files
|
.files
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|f| {
|
.map(|f| VersionFile {
|
||||||
VersionFile {
|
url: f.url,
|
||||||
url: f.url,
|
filename: f.filename,
|
||||||
filename: f.filename,
|
hashes: f.hashes,
|
||||||
// FIXME: Hashes are currently stored as an ascii byte slice instead
|
primary: f.primary,
|
||||||
// of as an actual byte array in the database
|
size: f.size,
|
||||||
hashes: f
|
|
||||||
.hashes
|
|
||||||
.into_iter()
|
|
||||||
.map(|(k, v)| Some((k, String::from_utf8(v).ok()?)))
|
|
||||||
.collect::<Option<_>>()
|
|
||||||
.unwrap_or_default(),
|
|
||||||
primary: f.primary,
|
|
||||||
size: f.size,
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
dependencies: data
|
dependencies: data
|
||||||
|
|||||||
+2
-4
@@ -321,8 +321,7 @@ pub async fn version_file_sha1(
|
|||||||
|
|
||||||
Ok(find_file(&project_id, &project, &version, &file)
|
Ok(find_file(&project_id, &project, &version, &file)
|
||||||
.and_then(|file| file.hashes.get("sha1"))
|
.and_then(|file| file.hashes.get("sha1"))
|
||||||
.and_then(|hash_bytes| std::str::from_utf8(hash_bytes).ok())
|
.map(|hash_str| HttpResponse::Ok().body(hash_str.clone()))
|
||||||
.map(|hash_str| HttpResponse::Ok().body(hash_str.to_string()))
|
|
||||||
.unwrap_or_else(|| HttpResponse::NotFound().body("")))
|
.unwrap_or_else(|| HttpResponse::NotFound().body("")))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,7 +386,6 @@ pub async fn version_file_sha512(
|
|||||||
|
|
||||||
Ok(find_file(&project_id, &project, &version, &file)
|
Ok(find_file(&project_id, &project, &version, &file)
|
||||||
.and_then(|file| file.hashes.get("sha512"))
|
.and_then(|file| file.hashes.get("sha512"))
|
||||||
.and_then(|hash_bytes| std::str::from_utf8(hash_bytes).ok())
|
.map(|hash_str| HttpResponse::Ok().body(hash_str.clone()))
|
||||||
.map(|hash_str| HttpResponse::Ok().body(hash_str.to_string()))
|
|
||||||
.unwrap_or_else(|| HttpResponse::NotFound().body("")))
|
.unwrap_or_else(|| HttpResponse::NotFound().body("")))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user