mirror of
https://github.com/zoriya/flood.git
synced 2025-12-06 07:16:18 +00:00
server: fileUtil: properly use async createDirectory
This commit is contained in:
@@ -61,7 +61,7 @@ class RTorrentClientGatewayService extends ClientGatewayService {
|
|||||||
throw accessDeniedError();
|
throw accessDeniedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
createDirectory(destinationPath);
|
await createDirectory(destinationPath);
|
||||||
|
|
||||||
// Each torrent is sent individually because rTorrent might have small
|
// Each torrent is sent individually because rTorrent might have small
|
||||||
// XMLRPC request size limit. This allows the user to send files reliably.
|
// XMLRPC request size limit. This allows the user to send files reliably.
|
||||||
@@ -99,7 +99,7 @@ class RTorrentClientGatewayService extends ClientGatewayService {
|
|||||||
throw accessDeniedError();
|
throw accessDeniedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
createDirectory(destinationPath);
|
await createDirectory(destinationPath);
|
||||||
|
|
||||||
const methodCalls: MultiMethodCalls = urls.map((url) => {
|
const methodCalls: MultiMethodCalls = urls.map((url) => {
|
||||||
const additionalCalls: Array<string> = [];
|
const additionalCalls: Array<string> = [];
|
||||||
|
|||||||
@@ -38,14 +38,21 @@ export const sanitizePath = (input: string) => {
|
|||||||
return path.resolve(input).replace(controlRe, '');
|
return path.resolve(input).replace(controlRe, '');
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createDirectory = (directoryPath: string) => {
|
export const createDirectory = (directoryPath: string): Promise<void> => {
|
||||||
if (directoryPath) {
|
return new Promise<void>((resolve, reject) => {
|
||||||
fs.mkdir(directoryPath, {recursive: true}, (error) => {
|
if (directoryPath) {
|
||||||
if (error) {
|
fs.mkdir(directoryPath, {recursive: true}, (error) => {
|
||||||
console.trace('Error creating directory.', error);
|
if (error) {
|
||||||
}
|
console.trace('Error creating directory.', error);
|
||||||
});
|
reject();
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getDirectoryList = async (inputPath: string) => {
|
export const getDirectoryList = async (inputPath: string) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user