2024-02-13 08:48:47 -05:00
|
|
|
import { WatchOptions } from 'chokidar';
|
2024-02-02 04:18:00 +01:00
|
|
|
import { Stats } from 'node:fs';
|
|
|
|
|
import { FileReadOptions } from 'node:fs/promises';
|
|
|
|
|
import { Readable } from 'node:stream';
|
2024-03-20 23:53:07 +01:00
|
|
|
import { CrawlOptionsDto } from 'src/dtos/library.dto';
|
2023-02-03 10:16:25 -05:00
|
|
|
|
|
|
|
|
export interface ImmichReadStream {
|
2023-06-30 12:24:28 -04:00
|
|
|
stream: Readable;
|
|
|
|
|
type?: string;
|
|
|
|
|
length?: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ImmichZipStream extends ImmichReadStream {
|
|
|
|
|
addFile: (inputPath: string, filename: string) => void;
|
|
|
|
|
finalize: () => Promise<void>;
|
2023-02-03 10:16:25 -05:00
|
|
|
}
|
|
|
|
|
|
2023-03-21 22:49:19 -04:00
|
|
|
export interface DiskUsage {
|
|
|
|
|
available: number;
|
|
|
|
|
free: number;
|
|
|
|
|
total: number;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-03 10:16:25 -05:00
|
|
|
export const IStorageRepository = 'IStorageRepository';
|
|
|
|
|
|
2024-02-13 08:48:47 -05:00
|
|
|
export interface WatchEvents {
|
|
|
|
|
onReady(): void;
|
|
|
|
|
onAdd(path: string): void;
|
|
|
|
|
onChange(path: string): void;
|
|
|
|
|
onUnlink(path: string): void;
|
|
|
|
|
onError(error: Error): void;
|
|
|
|
|
}
|
2024-01-31 09:15:54 +01:00
|
|
|
|
2023-02-03 10:16:25 -05:00
|
|
|
export interface IStorageRepository {
|
2023-06-30 12:24:28 -04:00
|
|
|
createZipStream(): ImmichZipStream;
|
|
|
|
|
createReadStream(filepath: string, mimeType?: string | null): Promise<ImmichReadStream>;
|
2023-09-27 20:44:51 +02:00
|
|
|
readFile(filepath: string, options?: FileReadOptions<Buffer>): Promise<Buffer>;
|
|
|
|
|
writeFile(filepath: string, buffer: Buffer): Promise<void>;
|
2023-02-25 09:12:03 -05:00
|
|
|
unlink(filepath: string): Promise<void>;
|
|
|
|
|
unlinkDir(folder: string, options?: { recursive?: boolean; force?: boolean }): Promise<void>;
|
2023-09-25 17:07:21 +02:00
|
|
|
removeEmptyDirs(folder: string, self?: boolean): Promise<void>;
|
2023-05-26 08:52:52 -04:00
|
|
|
checkFileExists(filepath: string, mode?: number): Promise<boolean>;
|
2023-02-25 09:12:03 -05:00
|
|
|
mkdirSync(filepath: string): void;
|
2023-03-21 22:49:19 -04:00
|
|
|
checkDiskUsage(folder: string): Promise<DiskUsage>;
|
2023-08-01 21:56:10 -04:00
|
|
|
readdir(folder: string): Promise<string[]>;
|
2023-09-20 13:16:33 +02:00
|
|
|
stat(filepath: string): Promise<Stats>;
|
|
|
|
|
crawl(crawlOptions: CrawlOptionsDto): Promise<string[]>;
|
2024-03-14 01:52:30 -04:00
|
|
|
walk(crawlOptions: CrawlOptionsDto): AsyncGenerator<string>;
|
2023-12-29 18:41:33 +00:00
|
|
|
copyFile(source: string, target: string): Promise<void>;
|
|
|
|
|
rename(source: string, target: string): Promise<void>;
|
2024-03-05 23:23:06 +01:00
|
|
|
watch(paths: string[], options: WatchOptions, events: Partial<WatchEvents>): () => Promise<void>;
|
2024-02-11 21:40:34 -07:00
|
|
|
utimes(filepath: string, atime: Date, mtime: Date): Promise<void>;
|
2023-02-03 10:16:25 -05:00
|
|
|
}
|