Skip to content

Commit

Permalink
Allow for sequence number to be NULL (needed after decompress now)
Browse files Browse the repository at this point in the history
  • Loading branch information
danenbm committed Jun 22, 2023
1 parent f13f7d5 commit 2713a18
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
39 changes: 18 additions & 21 deletions digital_asset_types/src/dapi/common/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ pub fn get_mime(url: Url) -> Option<Mime> {

pub fn get_mime_type_from_uri(uri: String) -> String {
let default_mime_type = "image/png".to_string();
to_uri(uri).and_then(get_mime).map_or(default_mime_type, |m| m.to_string())
to_uri(uri)
.and_then(get_mime)
.map_or(default_mime_type, |m| m.to_string())
}

pub fn file_from_str(str: String) -> File {
Expand Down Expand Up @@ -173,28 +175,25 @@ pub fn v1_content_from_json(asset_data: &asset_data::Model) -> Result<Content, D
match (uri, mime_type) {
(Some(u), Some(m)) => {
if let Some(str_uri) = u.as_str() {
let file =
if let Some(str_mime) = m.as_str() {
File {
uri: Some(str_uri.to_string()),
mime: Some(str_mime.to_string()),
quality: None,
contexts: None,
}
} else {
warn!("Mime is not string: {:?}", m);
file_from_str(str_uri.to_string())
};
actual_files.insert(
str_uri.to_string().clone(),
file,
);
let file = if let Some(str_mime) = m.as_str() {
File {
uri: Some(str_uri.to_string()),
mime: Some(str_mime.to_string()),
quality: None,
contexts: None,
}
} else {
warn!("Mime is not string: {:?}", m);
file_from_str(str_uri.to_string())
};
actual_files.insert(str_uri.to_string().clone(), file);
} else {
warn!("URI is not string: {:?}", u);
}
}
(Some(u), None) => {
let str_uri = serde_json::to_string(u).unwrap_or_else(|_|String::new());
let str_uri =
serde_json::to_string(u).unwrap_or_else(|_| String::new());
actual_files.insert(str_uri.clone(), file_from_str(str_uri));
}
_ => {}
Expand Down Expand Up @@ -309,9 +308,7 @@ pub fn asset_to_rpc(asset: FullAsset) -> Result<RpcAsset, DbErr> {
leaf_id: asset
.nonce
.ok_or(DbErr::Custom("Nonce not found".to_string()))?,
seq: asset
.seq
.ok_or(DbErr::Custom("Seq not found".to_string()))?,
seq: asset.seq,
tree: asset
.tree_id
.map(|s| bs58::encode(s).into_string())
Expand Down
2 changes: 1 addition & 1 deletion digital_asset_types/src/rpc/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ pub struct Compression {
pub creator_hash: String,
pub asset_hash: String,
pub tree: String,
pub seq: i64,
pub seq: Option<i64>,
pub leaf_id: i64,
}

Expand Down

0 comments on commit 2713a18

Please sign in to comment.