diff options
Diffstat (limited to 'src/routes/api/v1')
| -rw-r--r-- | src/routes/api/v1/fs.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/routes/api/v1/fs.ts b/src/routes/api/v1/fs.ts new file mode 100644 index 0000000..92714f3 --- /dev/null +++ b/src/routes/api/v1/fs.ts @@ -0,0 +1,20 @@ +import { LockSet } from '$lib/vendor/lock'; +import fs from 'node:fs/promises'; +import process from 'node:process'; +import path from 'node:path'; + +const lockSet = new LockSet(); +const baseDataPath = + process.env.BASE_DATA_PATH ?? path.join(process.cwd(), 'data'); +const usersDir = path.join(baseDataPath, 'users'); +const disksDir = path.join(baseDataPath, 'disks'); + +export const userExists = async (username: string) => { + const unlock = await lockSet.get(username).acquireRead(); + try { + fs.open(path.join(baseDataPath, '')); + } catch (error) { + unlock(); + throw error; + } +}; |