Skip to content

Commit

Permalink
Fixed bug in path for downloaded images and pdfs
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmerfield committed Feb 14, 2019
1 parent 8d6907d commit 93b8778
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
18 changes: 12 additions & 6 deletions app/dashboard/routes/importer/helper/download_images.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,22 @@ module.exports = function download_images(post, callback) {
});
})
.catch(function(err) {
console.log("Image error", src, err);
console.log("Image error:", src, err.name, err.statusCode);
return next();
});
},
function() {
if (changes) {
post.path = post.path + "/post.txt";
} else {
post.path = post.path + ".txt";
}

// Download PDFS or download images might have already moved the output
// path for this file into its own folder, so check.
if (changes && post.path.slice(-'/post.txt'.length) !== '/post.txt') {
post.path = post.path + "/post.txt";
}

if (!changes && post.path.slice(-'.txt'.length) !== '.txt') {
post.path = post.path + ".txt";
}


post.html = $.html();

Expand Down
11 changes: 9 additions & 2 deletions app/dashboard/routes/importer/helper/download_pdfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,21 @@ module.exports = function download_pdfs(post, callback) {
});
})
.catch(function(err) {
console.log("PDF error", href, err);
console.log("PDF error:", href, err.name, err.statusCode);
return next();
});
},
function() {
if (changes) {
// Download PDFS or download images might have already moved the output
// path for this file into its own folder, so check.
if (changes && post.path.slice(-'/post.txt'.length) !== '/post.txt') {
post.path = post.path + "/post.txt";
}

if (!changes && post.path.slice(-'.txt'.length) !== '.txt') {
post.path = post.path + ".txt";
}

post.html = $.html();
callback(null, post);
}
Expand Down

0 comments on commit 93b8778

Please sign in to comment.