mirror of
https://github.com/narrrl/proton-sdk-rs.git
synced 2026-11-03 16:41:26 +01:00
fixed photo deserial
This commit is contained in:
1 parent
2716be77ef
commit
9ec205f217
2 files changed
+18
-1
No files matched your search
@@ -470,6 +470,7 @@ impl ProtonDriveClient {
|
|||||||
let link = detail.link;
|
let link = detail.link;
|
||||||
let file = detail
|
let file = detail
|
||||||
.file
|
.file
|
||||||
|
.or(detail.photo)
|
||||||
.ok_or_else(|| ProtonError::invalid_operation(format!("node {uid} is not a file")))?;
|
.ok_or_else(|| ProtonError::invalid_operation(format!("node {uid} is not a file")))?;
|
||||||
|
|
||||||
let content_key_packet_b64 = file.content_key_packet.ok_or_else(|| {
|
let content_key_packet_b64 = file.content_key_packet.ok_or_else(|| {
|
||||||
@@ -559,6 +560,7 @@ impl ProtonDriveClient {
|
|||||||
let link = detail.link;
|
let link = detail.link;
|
||||||
let file = detail
|
let file = detail
|
||||||
.file
|
.file
|
||||||
|
.or(detail.photo)
|
||||||
.ok_or_else(|| ProtonError::invalid_operation(format!("node {uid} is not a file")))?;
|
.ok_or_else(|| ProtonError::invalid_operation(format!("node {uid} is not a file")))?;
|
||||||
|
|
||||||
let content_key_packet_b64 = file.content_key_packet.ok_or_else(|| {
|
let content_key_packet_b64 = file.content_key_packet.ok_or_else(|| {
|
||||||
@@ -896,6 +898,7 @@ impl ProtonDriveClient {
|
|||||||
let link = detail.link;
|
let link = detail.link;
|
||||||
let file = detail
|
let file = detail
|
||||||
.file
|
.file
|
||||||
|
.or(detail.photo)
|
||||||
.ok_or_else(|| ProtonError::invalid_operation(format!("node {uid} is not a file")))?;
|
.ok_or_else(|| ProtonError::invalid_operation(format!("node {uid} is not a file")))?;
|
||||||
|
|
||||||
let content_key_packet_b64 = file.content_key_packet.ok_or_else(|| {
|
let content_key_packet_b64 = file.content_key_packet.ok_or_else(|| {
|
||||||
@@ -2322,6 +2325,7 @@ impl ProtonDriveClient {
|
|||||||
let link = detail.link;
|
let link = detail.link;
|
||||||
let file = detail
|
let file = detail
|
||||||
.file
|
.file
|
||||||
|
.or(detail.photo)
|
||||||
.ok_or_else(|| ProtonError::invalid_operation(format!("node {uid} is not a file")))?;
|
.ok_or_else(|| ProtonError::invalid_operation(format!("node {uid} is not a file")))?;
|
||||||
|
|
||||||
let content_key_packet_b64 = file.content_key_packet.ok_or_else(|| {
|
let content_key_packet_b64 = file.content_key_packet.ok_or_else(|| {
|
||||||
@@ -2532,7 +2536,7 @@ impl ProtonDriveClient {
|
|||||||
NodeKind::Folder
|
NodeKind::Folder
|
||||||
}
|
}
|
||||||
LinkType::File => {
|
LinkType::File => {
|
||||||
let file = details.file.as_ref().ok_or_else(|| {
|
let file = details.file_properties().ok_or_else(|| {
|
||||||
ProtonError::invalid_operation("file node missing file properties")
|
ProtonError::invalid_operation("file node missing file properties")
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,19 @@ pub struct LinkDetailsDto {
|
|||||||
pub folder: Option<FolderDto>,
|
pub folder: Option<FolderDto>,
|
||||||
#[serde(rename = "File")]
|
#[serde(rename = "File")]
|
||||||
pub file: Option<FileDto>,
|
pub file: Option<FileDto>,
|
||||||
|
/// Photos-volume `/links` returns file properties under `Photo` (a superset
|
||||||
|
/// of `File`) rather than `File`. Deserialized as [`FileDto`]; the extra
|
||||||
|
/// photo fields are ignored. C# `linkDetailsDto.File ?? linkDetailsDto.Photo`.
|
||||||
|
#[serde(rename = "Photo")]
|
||||||
|
pub photo: Option<FileDto>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LinkDetailsDto {
|
||||||
|
/// File properties for a file/photo node, preferring `File` and falling back
|
||||||
|
/// to the photos-volume `Photo` block.
|
||||||
|
pub fn file_properties(&self) -> Option<&FileDto> {
|
||||||
|
self.file.as_ref().or(self.photo.as_ref())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
|
|||||||
Reference in new issue
Block a user