mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-24 21:40:48 +02:00
feat(fs): accept baseDir in size (#3623)
In plugins/fs/guest-js/index.ts, the size function only sent `path`
although the Rust command accepts `options.baseDir` and the JSDoc example
passed `{ baseDir: BaseDirectory.AppData }` (a TS error, silently dropped
at runtime, so the relative path was rejected).
Adds an optional `options?: SizeOptions` parameter (new exported type).
api-iife.js regenerated. The e2e spec now measures a file and a directory
relative to AppData instead of working around the missing option.
This commit is contained in:
@@ -116,10 +116,11 @@ describePlugin('fs', () => {
|
||||
hasMtime: fileStat.mtime instanceof Date
|
||||
},
|
||||
lstatSize: fileLstat.size,
|
||||
// `size` only takes absolute paths
|
||||
size: await api.fs.size(
|
||||
size: await api.fs.size(file, { baseDir }),
|
||||
absoluteSize: await api.fs.size(
|
||||
await api.path.join(await api.path.appDataDir(), file)
|
||||
),
|
||||
dirSize: await api.fs.size(dir, { baseDir }),
|
||||
dir: { isFile: dirStat.isFile, isDirectory: dirStat.isDirectory }
|
||||
}
|
||||
}, dir)
|
||||
@@ -132,6 +133,8 @@ describePlugin('fs', () => {
|
||||
})
|
||||
expect(result.lstatSize).toBe(10)
|
||||
expect(result.size).toBe(10)
|
||||
expect(result.absoluteSize).toBe(10)
|
||||
expect(result.dirSize).toBeGreaterThanOrEqual(10)
|
||||
expect(result.dir).toEqual({ isFile: false, isDirectory: true })
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user