Skip to content

fix: add a file "shared drive" metadata to rules#4763

Merged
shepilov merged 1 commit into
masterfrom
fix/file_share_drive_mime_type
May 21, 2026
Merged

fix: add a file "shared drive" metadata to rules#4763
shepilov merged 1 commit into
masterfrom
fix/file_share_drive_mime_type

Conversation

@shepilov
Copy link
Copy Markdown
Contributor

@shepilov shepilov commented May 20, 2026

Context

linagora/twake-drive#3850

Make rules[0].mime for file-root shared drives a derived value from the VFS file as far as UI use this field to check that the shared drive is a file and doesn't use specific field

Changes:

  • Add the root file MIME to shared-drive rules.
  • Add drive_root_type to recipient shortcut target metadata.
  • Add shortcut target MIME for file-root shared drives.
  • Canonicalize drive_root_type from the real VFS root instead of trusting legacy input.
  • Make invalid drive root inference fail instead of silently creating incomplete metadata.

Assumptions

  • The VFS file document MIME is the trusted source of truth.
  • Client-provided rule MIME should never be preserved for file-root shared drive creation.
  • Directory-root shared drives should still not get a synthetic rule MIME.

@shepilov shepilov requested a review from a team as a code owner May 20, 2026 13:13
Comment thread model/sharing/sharing.go
Comment on lines +487 to +491
rule := s.FirstFilesRule()
if rule == nil || rule.Selector == couchdb.SelectorReferencedBy || len(rule.Values) == 0 {
return ErrDriveRootNotFound
}
rootID := rule.Values[0]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too bad we have to duplicate this code to get access to the rule :/.
I find rule.Values[0] not to be clear it represents the drive ID and was happy to see it used only in a helper.

But I don't have a better version to offer at the moment.

Comment thread model/sharing/sharing.go Outdated
Comment on lines +526 to +529
rootMime := ""
if file != nil {
rootMime = file.Mime
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the declaration of rootMime could be moved with the declarations of rootType and rootName and the re-assignment of rootMime moved into the file block above.

@shepilov shepilov force-pushed the fix/file_share_drive_mime_type branch from 31c926b to f689828 Compare May 21, 2026 12:23
@shepilov shepilov merged commit 78f9cd4 into master May 21, 2026
4 checks passed
@shepilov shepilov deleted the fix/file_share_drive_mime_type branch May 21, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants