From 315073b4d4e04a0e4f2912838d600f70245275d8 Mon Sep 17 00:00:00 2001 From: tomholford Date: Tue, 6 Jan 2026 17:02:10 -0800 Subject: [PATCH] feat(drive): add ClientUID support for draft ownership tracking Add ClientUID field to Drive API types per official Proton Drive OpenAPI spec: - CreateFileReq.ClientUID: identifies which client created a file draft - CheckAvailableHashesReq.ClientUID: filters pending drafts by client UIDs - CheckAvailableHashesRes/PendingHashData: returns draft ownership info This enables clients to: - Safely auto-replace their own failed upload drafts - Avoid overwriting concurrent uploads from other clients Reference: ProtonDriveApps/sdk driveTypes.ts (auto-generated from OpenAPI) --- link_file_types.go | 5 +++++ link_types.go | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/link_file_types.go b/link_file_types.go index 16344e0..5781615 100644 --- a/link_file_types.go +++ b/link_file_types.go @@ -7,6 +7,11 @@ type CreateFileReq struct { Hash string // Encrypted content hash MIMEType string // MIME Type + // ClientUID is used for draft ownership tracking. In case of upload failure, + // the client can recognize its own draft and continue the upload. + // Per official Proton Drive API (OpenAPI spec). + ClientUID string `json:",omitempty"` + ContentKeyPacket string // The block's key packet, encrypted with the node key. ContentKeyPacketSignature string // Unencrypted signature of the content session key, signed with the NodeKey diff --git a/link_types.go b/link_types.go index 387f240..cf37930 100644 --- a/link_types.go +++ b/link_types.go @@ -182,3 +182,29 @@ const ( RevisionStateObsolete RevisionStateDeleted ) + +// CheckAvailableHashesReq is used to check which file name hashes are available +// for upload in a given folder. Per official Proton Drive API (OpenAPI spec). +type CheckAvailableHashesReq struct { + Hashes []string + + // ClientUID filters pending drafts. If provided, only drafts NOT belonging + // to these client UIDs will be returned in PendingHashes. + ClientUID []string `json:",omitempty"` +} + +// CheckAvailableHashesRes contains the results of a hash availability check. +type CheckAvailableHashesRes struct { + AvailableHashes []string + PendingHashes []PendingHashData +} + +// PendingHashData represents a pending draft that conflicts with a requested hash. +type PendingHashData struct { + Hash string + RevisionID string + LinkID string + + // ClientUID identifies which client created this pending draft. + ClientUID string `json:",omitempty"` +}