mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-11 00:10:29 -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, getFileAbosluteDir, getSubStem,
|
||||
} from '../../../../FlowHelpers/1.0.0/fileUtils';
|
||||
|
|
@ -188,7 +188,7 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
|||
sourceDir = getFileAbosluteDir(args.inputFileObj._id);
|
||||
}
|
||||
|
||||
let filesInDir = (await fs.readdir(sourceDir))
|
||||
let filesInDir = (await fsp.readdir(sourceDir))
|
||||
.map((row) => ({
|
||||
source: `${sourceDir}/${row}`,
|
||||
destination: normJoinPath({
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { promises as fs } from 'fs';
|
||||
import { promises as fsp } from 'fs';
|
||||
import { getContainer, getFileName, getSubStem } from '../../../../FlowHelpers/1.0.0/fileUtils';
|
||||
import {
|
||||
IpluginDetails,
|
||||
|
|
@ -126,7 +126,7 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
|||
|
||||
args.deps.fsextra.ensureDirSync(outputPath);
|
||||
|
||||
await fs.copyFile(args.inputFileObj._id, ouputFilePath);
|
||||
await fsp.copyFile(args.inputFileObj._id, ouputFilePath);
|
||||
|
||||
return {
|
||||
outputFileObj: {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { promises as fs } from 'fs';
|
||||
import { promises as fsp } from 'fs';
|
||||
import { getContainer, getFileName } from '../../../../FlowHelpers/1.0.0/fileUtils';
|
||||
import {
|
||||
IpluginDetails,
|
||||
|
|
@ -67,7 +67,7 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
|||
|
||||
args.deps.fsextra.ensureDirSync(outputPath);
|
||||
|
||||
await fs.copyFile(args.inputFileObj._id, ouputFilePath);
|
||||
await fsp.copyFile(args.inputFileObj._id, ouputFilePath);
|
||||
|
||||
return {
|
||||
outputFileObj: {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { promises as fs } from 'fs';
|
||||
import { promises as fsp } from 'fs';
|
||||
|
||||
import {
|
||||
IpluginDetails,
|
||||
IpluginInputArgs,
|
||||
|
|
@ -64,21 +65,21 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
|||
|
||||
if (fileToDelete === 'workingFile') {
|
||||
args.jobLog(`Deleting working file ${args.inputFileObj._id}`);
|
||||
await fs.unlink(args.inputFileObj._id);
|
||||
await fsp.unlink(args.inputFileObj._id);
|
||||
} else if (fileToDelete === 'originalFile') {
|
||||
args.jobLog(`Deleting original file ${args.originalLibraryFile._id}`);
|
||||
await fs.unlink(args.originalLibraryFile._id);
|
||||
await fsp.unlink(args.originalLibraryFile._id);
|
||||
}
|
||||
|
||||
const fileDir = getFileAbosluteDir(args.originalLibraryFile._id);
|
||||
|
||||
if (deleteParentFolderIfEmpty) {
|
||||
args.jobLog(`Checking if folder ${fileDir} is empty`);
|
||||
const files = await fs.readdir(fileDir);
|
||||
const files = await fsp.readdir(fileDir);
|
||||
|
||||
if (files.length === 0) {
|
||||
args.jobLog(`Deleting empty folder ${fileDir}`);
|
||||
await fs.rmdir(fileDir);
|
||||
await fsp.rmdir(fileDir);
|
||||
} else {
|
||||
args.jobLog(`Folder ${fileDir} is not empty, skipping delete`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue