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();
|
||||
}
|
||||
|
||||
createDirectory(destinationPath);
|
||||
await createDirectory(destinationPath);
|
||||
|
||||
// Each torrent is sent individually because rTorrent might have small
|
||||
// XMLRPC request size limit. This allows the user to send files reliably.
|
||||
@@ -99,7 +99,7 @@ class RTorrentClientGatewayService extends ClientGatewayService {
|
||||
throw accessDeniedError();
|
||||
}
|
||||
|
||||
createDirectory(destinationPath);
|
||||
await createDirectory(destinationPath);
|
||||
|
||||
const methodCalls: MultiMethodCalls = urls.map((url) => {
|
||||
const additionalCalls: Array<string> = [];
|
||||
|
||||
@@ -38,14 +38,21 @@ export const sanitizePath = (input: string) => {
|
||||
return path.resolve(input).replace(controlRe, '');
|
||||
};
|
||||
|
||||
export const createDirectory = (directoryPath: string) => {
|
||||
export const createDirectory = (directoryPath: string): Promise<void> => {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
if (directoryPath) {
|
||||
fs.mkdir(directoryPath, {recursive: true}, (error) => {
|
||||
if (error) {
|
||||
console.trace('Error creating directory.', error);
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const getDirectoryList = async (inputPath: string) => {
|
||||
|
||||
Reference in New Issue
Block a user