fixed photo deserial

This commit is contained in:
nvrl committed 2026-06-30 03:29:25 +02:00
1 parent 2716be77ef
commit 9ec205f217
2 files changed
+18 -1

No files matched your search

+5 -1
View File
@@ -470,6 +470,7 @@ impl ProtonDriveClient {
let link = detail.link;
let file = detail
.file
.or(detail.photo)
.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(|| {
@@ -559,6 +560,7 @@ impl ProtonDriveClient {
let link = detail.link;
let file = detail
.file
.or(detail.photo)
.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(|| {
@@ -896,6 +898,7 @@ impl ProtonDriveClient {
let link = detail.link;
let file = detail
.file
.or(detail.photo)
.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(|| {
@@ -2322,6 +2325,7 @@ impl ProtonDriveClient {
let link = detail.link;
let file = detail
.file
.or(detail.photo)
.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(|| {
@@ -2532,7 +2536,7 @@ impl ProtonDriveClient {
NodeKind::Folder
}
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")
})?;
+13
View File
@@ -100,6 +100,19 @@ pub struct LinkDetailsDto {
pub folder: Option<FolderDto>,
#[serde(rename = "File")]
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)]