mirror of
https://github.com/docmost/docmost.git
synced 2025-11-17 16:11:10 +10:00
fix types
This commit is contained in:
@ -20,24 +20,24 @@ export class LocalDriver implements StorageDriver {
|
||||
async upload(filePath: string, file: Buffer): Promise<void> {
|
||||
try {
|
||||
await fs.outputFile(this._fullPath(filePath), file);
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to upload file: ${error.message}`);
|
||||
} catch (err) {
|
||||
throw new Error(`Failed to upload file: ${(err as Error).message}`);
|
||||
}
|
||||
}
|
||||
|
||||
async read(filePath: string): Promise<Buffer> {
|
||||
try {
|
||||
return await fs.readFile(this._fullPath(filePath));
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to read file: ${error.message}`);
|
||||
} catch (err) {
|
||||
throw new Error(`Failed to read file: ${(err as Error).message}`);
|
||||
}
|
||||
}
|
||||
|
||||
async exists(filePath: string): Promise<boolean> {
|
||||
try {
|
||||
return await fs.pathExists(this._fullPath(filePath));
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to check file existence: ${error.message}`);
|
||||
} catch (err) {
|
||||
throw new Error(`Failed to check file existence: ${(err as Error).message}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,8 +52,8 @@ export class LocalDriver implements StorageDriver {
|
||||
async delete(filePath: string): Promise<void> {
|
||||
try {
|
||||
await fs.remove(this._fullPath(filePath));
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to delete file: ${error.message}`);
|
||||
} catch (err) {
|
||||
throw new Error(`Failed to delete file: ${(err as Error).message}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -38,8 +38,8 @@ export class S3Driver implements StorageDriver {
|
||||
// we can get the path from location
|
||||
|
||||
console.log(`File uploaded successfully: ${filePath}`);
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to upload file: ${error.message}`);
|
||||
} catch (err) {
|
||||
throw new Error(`Failed to upload file: ${(err as Error).message}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,8 +53,8 @@ export class S3Driver implements StorageDriver {
|
||||
const response = await this.s3Client.send(command);
|
||||
|
||||
return streamToBuffer(response.Body as Readable);
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to read file from S3: ${error.message}`);
|
||||
} catch (err) {
|
||||
throw new Error(`Failed to read file from S3: ${(err as Error).message}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ export class S3Driver implements StorageDriver {
|
||||
await this.s3Client.send(command);
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
`Error deleting file ${filePath} from S3. ${err.message}`,
|
||||
`Error deleting file ${filePath} from S3. ${(err as Error).message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user