Skip to content

Conversation

@okerekechinweotito
Copy link
Contributor

Fixes: T348412

Proposed Changes

  • When PDL fails to return an image the file should not be uploaded and must fail with a valid reason.

Files Created/Updated

  • bull/pdl-queue/consumer.js - adds an isError boolean to getZipAndBytelength return statement that validates if downloadImage is not returning a 500 server error. If it returns a 500, then the upload fails with a valid reason

Current Look

Screenshot (35)

Checklist

  • Coding Conventions are followed.
  • Comments are used for Documenting the Code.
  • Correct File Names are mentioned.

downloadImageStatus = await download_image(str, `${title}_${i}.jpeg`);
job.progress(Math.round((i / temp_pages) * 82));
}
let isError = downloadImageStatus === 500 ? true : false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the error is not 500 but 503 or 404 or something else? We should handle all the possible failures. I suggest check for 2xx, else return failure.

@okerekechinweotito
Copy link
Contributor Author

@coderwassananmol I have made the requested changes

done(null, true);

if (isError) {
logger.log({
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please log in the job logs as well including username.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coderwassananmol
I have made the requested changes

Copy link
Owner

@coderwassananmol coderwassananmol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@okerekechinweotito Currently, we are traversing through each image in a for loop and even though the first x pages could return 500 and even if the last page is successful, we will return it as success but in reality the book will be uploaded incomplete.
The expectation is that even if a single page fails to load, we will NOT upload the book to Internet Archive. The error must be logged and the upload must entirely fail. The failed reason should say: "Upload to Internet Archive failed because {link to the first inaccessible page} is not reachable. Please try again or contact Panjab Digital Library for more details."

@okerekechinweotito
Copy link
Contributor Author

@coderwassananmol I have pushed a possible fix for that

Screenshot (46)

job.progress(100);
done(
new Error(
`Upload to Internet Archive failed because ${errorFlag.page} is not reachable. Please try again or contact Panjab Digital Library for more details.`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a href to this with target="_blank" so that it opens up in a new tab when user clicks on it?

Copy link
Owner

@coderwassananmol coderwassananmol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add href to the link. Rest seems to be working.

@okerekechinweotito
Copy link
Contributor Author

@coderwassananmol I have pushed a possible fix for that

Screenshot (47)

Copy link
Owner

@coderwassananmol coderwassananmol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@coderwassananmol coderwassananmol merged commit 008cb3e into coderwassananmol:develop Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants