mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-13 17:30:27 -07:00
Use fsp for promises
This commit is contained in:
parent
a5714ebf34
commit
e08aa2356d
10 changed files with 27 additions and 26 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { promises as fs } from 'fs';
|
||||
import { promises as fsp } from 'fs';
|
||||
import {
|
||||
getContainer, getFileName, getPluginWorkDir, getScanTypes,
|
||||
} from './fileUtils';
|
||||
|
|
@ -43,7 +43,7 @@ export const runClassicPlugin = async (args:IpluginInputArgs, type:'filter'|'tra
|
|||
let pluginSrcStr = '';
|
||||
if (pluginSource === 'Community') {
|
||||
classicPlugin = args.deps.importFresh(relativePluginPath);
|
||||
pluginSrcStr = await fs.readFile(absolutePath, 'utf8');
|
||||
pluginSrcStr = await fsp.readFile(absolutePath, 'utf8');
|
||||
} else {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const res = await args.deps.axiosMiddleware('api/v2/read-plugin', {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { promises as fs } from 'fs';
|
||||
import { promises as fsp } from 'fs';
|
||||
|
||||
import { getFileSize } from './fileUtils';
|
||||
import { IpluginInputArgs } from './interfaces/interfaces';
|
||||
|
|
@ -48,7 +48,7 @@ const tryMove = async ({
|
|||
|
||||
let error = false;
|
||||
try {
|
||||
await fs.rename(sourcePath, destinationPath);
|
||||
await fsp.rename(sourcePath, destinationPath);
|
||||
} catch (err) {
|
||||
error = true;
|
||||
args.jobLog(`File move error: ${JSON.stringify(err)}`);
|
||||
|
|
@ -157,7 +157,7 @@ const tryNormalCopy = async ({
|
|||
|
||||
let error = false;
|
||||
try {
|
||||
await fs.copyFile(sourcePath, destinationPath);
|
||||
await fsp.copyFile(sourcePath, destinationPath);
|
||||
} catch (err) {
|
||||
error = true;
|
||||
args.jobLog(`File copy error: ${JSON.stringify(err)}`);
|
||||
|
|
@ -186,7 +186,7 @@ const cleanSourceFile = async ({
|
|||
}) => {
|
||||
try {
|
||||
args.jobLog(`Deleting source file ${sourcePath}`);
|
||||
await fs.unlink(sourcePath);
|
||||
await fsp.unlink(sourcePath);
|
||||
} catch (err) {
|
||||
args.jobLog(`Failed to delete source file ${sourcePath}: ${JSON.stringify(err)}`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { promises as fs } from 'fs';
|
||||
import { promises as fsp } from 'fs';
|
||||
import { IpluginInputArgs } from './interfaces/interfaces';
|
||||
|
||||
export const getContainer = (filePath: string): string => {
|
||||
|
|
@ -37,7 +37,7 @@ export const getSubStem = ({
|
|||
};
|
||||
|
||||
export const getFileSize = async (file:string):Promise<number> => {
|
||||
const stats = await fs.stat(file);
|
||||
const stats = await fsp.stat(file);
|
||||
const { size } = stats;
|
||||
return size;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue