mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-01 16:12:02 +00:00
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.
22 lines
931 B
TypeScript
22 lines
931 B
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { fileNodeKind } from '../jmap/filenode-kind';
|
|
|
|
describe('fileNodeKind', () => {
|
|
it('takes nodeType as Stalwart 0.16.6+ returns it', () => {
|
|
expect(fileNodeKind({ nodeType: 'file', blobId: 'b1' })).toBe('file');
|
|
expect(fileNodeKind({ nodeType: 'directory', blobId: null })).toBe('directory');
|
|
});
|
|
|
|
// 1.0 symlinks: `blobId`, `size` and `type` are null, like a folder's.
|
|
it('tells a symlink from a folder on Stalwart 1.0', () => {
|
|
expect(fileNodeKind({ nodeType: 'symlink', blobId: null })).toBe('symlink');
|
|
});
|
|
|
|
it('falls back to the blob rule without nodeType (#379)', () => {
|
|
expect(fileNodeKind({ blobId: null })).toBe('directory');
|
|
expect(fileNodeKind({ blobId: 'b1' })).toBe('file');
|
|
// An unknown value from some other server doesn't count.
|
|
expect(fileNodeKind({ nodeType: 'fifo' as never, blobId: 'b1' })).toBe('file');
|
|
});
|
|
});
|