Skip to content
This repository has been archived by the owner on Feb 23, 2021. It is now read-only.

Commit

Permalink
Merge bf8d418 into f745823
Browse files Browse the repository at this point in the history
  • Loading branch information
tamarahills committed Sep 23, 2018
2 parents f745823 + bf8d418 commit 8470984
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion command/polly_tts.js
Expand Up @@ -264,7 +264,7 @@ var polly_tts = {
// Return the URL of the Mp3 in the S3 bucket.
resolve(data.Location);
// Remove the files locally.
polly_tts.deleteLocalFiles(audio_file, function(err) {
polly_tts.deleteLocalFiles(newAudioFile, function(err) {
if (err) {
logger.error('Error removing files ' + err);
} else {
Expand Down Expand Up @@ -323,13 +323,18 @@ var polly_tts = {
logger.debug('Entering deleteLocalFiles: ' + rootFile);
let files = glob.sync(rootFile.replace('.mp3', '*.*'));
var i = files.length;
logger.debug('There are: ' + i + ' files to delete.');
files.forEach(function(filepath) {
logger.debug('unlinking: ' + filepath);
fs.unlink(filepath, function(err) {
i--;
if (err) {
logger.error('Error deleting file: ' + filepath);
logger.error('Error is: ' + err);
callback(err);
return;
} else if (i <= 0) {
logger.debug('Calling the callback for deleting files');
callback(null);
}
});
Expand Down

0 comments on commit 8470984

Please sign in to comment.