chore: Normalize fs-extra usage
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import fs from "fs";
|
||||
import fs from "fs-extra";
|
||||
import truncate from "lodash/truncate";
|
||||
import { FileOperationState, NotificationEventType } from "@shared/types";
|
||||
import { bytesToHumanReadable } from "@shared/utils/files";
|
||||
@@ -89,7 +89,7 @@ export default abstract class ExportTask extends BaseTask<Props> {
|
||||
state: FileOperationState.Uploading,
|
||||
});
|
||||
|
||||
const stat = await fs.promises.stat(filePath);
|
||||
const stat = await fs.stat(filePath);
|
||||
const url = await FileStorage.store({
|
||||
body: fs.createReadStream(filePath),
|
||||
contentLength: stat.size,
|
||||
@@ -129,7 +129,7 @@ export default abstract class ExportTask extends BaseTask<Props> {
|
||||
throw error;
|
||||
} finally {
|
||||
if (filePath) {
|
||||
void fs.promises.unlink(filePath).catch((error) => {
|
||||
void fs.unlink(filePath).catch((error) => {
|
||||
Logger.error(`Failed to delete temporary file ${filePath}`, error);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import path from "path";
|
||||
import { rm } from "fs-extra";
|
||||
import fs from "fs-extra";
|
||||
import truncate from "lodash/truncate";
|
||||
import tmp from "tmp";
|
||||
import {
|
||||
@@ -248,7 +248,7 @@ export default abstract class ImportTask extends BaseTask<Props> {
|
||||
fileOperation: FileOperation
|
||||
) {
|
||||
try {
|
||||
await rm(dirPath, { recursive: true, force: true });
|
||||
await fs.rm(dirPath, { recursive: true, force: true });
|
||||
} catch (error) {
|
||||
Logger.error(
|
||||
`ImportTask failed to cleanup extracted data for ${fileOperation.id}`,
|
||||
|
||||
Reference in New Issue
Block a user