Files
webmail/lib/jmap/filenode-kind.ts
T
Linus Rath 92de8e99bd fix: show Stalwart 1.0 symlinks as links instead of empty folders
Bulwark counted a FileNode as a folder when it had no blobId. Stalwart
1.0 adds symlinks, which have no blob either, so they showed up as
empty folders that could be opened, and folder copies recreated them
as such. Listings now ask for `nodeType` (returned since 0.16.6) and a
single helper, `fileNodeKind()`, decides what a node is in the Files
store, the copy code and the global search, falling back to the blobId
rule when `nodeType` is missing. `nodeType` is never sent in
FileNode/set.

A symlink is shown as an inert row with a link icon. It can be renamed,
moved and deleted, but not opened, previewed, downloaded, copied or
shared, and folder copies skip it.
2026-09-25 18:35:47 +02:00

21 lines
673 B
TypeScript

import type { FileNode, FileNodeType } from './types';
/**
* What a FileNode is: a file, a folder or a symlink.
*
* `nodeType` says so on Stalwart 0.16.6 and later. Without it, a node is a
* folder exactly when it has no content blob (#379). Stalwart 1.0 adds
* symlinks, which have no blob either but can't hold anything, so the blob
* rule alone would show them as empty folders.
*/
export function fileNodeKind(node: Pick<FileNode, 'nodeType' | 'blobId'>): FileNodeType {
switch (node.nodeType) {
case 'file':
case 'directory':
case 'symlink':
return node.nodeType;
default:
return node.blobId == null ? 'directory' : 'file';
}
}