Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions api/src/models/Job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Job {
queue: QueueManager;

constructor(dir: string, config: Config, queue: QueueManager) {
this.dir = dir;
this.dir = dir.endsWith("/") ? dir : dir + "/";
Copy link
Collaborator

Choose a reason for hiding this comment

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

It also occurred to me that if we wanted to trim the trailing slash rather than normalize it on, we could use a regular expression, like:

this.dir = dir.replace(/\/+$/, "");

... while I still think I like having the leading underscore, I do wonder if it's more technically correct not to have it. Maybe the right thing to do would be to fix the bug by stripping the trailing slash, and then add a feature where we can define a "job name prefix" value in the config file. That might be best of both worlds. I also suggest this in part because fewer tests may fail if we go in the opposite direction.

Anyway, just giving options for you to think about. We can discuss further!

this.name = path.basename(dir);
this.config = config;
this.queue = queue;
Expand All @@ -39,7 +39,7 @@ class Job {
}

getImage(fileName: string): ImageFile {
return ImageFile.build(this.dir + "/" + fileName);
return ImageFile.build(this.dir + fileName);
}

async makeDerivatives(): Promise<void> {
Expand Down Expand Up @@ -73,14 +73,14 @@ class Job {
const pages = this.metadata.order.pages;
const jpegs = [];
for (const i in pages) {
const image = ImageFile.build(this.dir + "/" + pages[i].filename);
const image = ImageFile.build(this.dir + pages[i].filename);
jpegs[i] = await image.derivative("LARGE");
}
return jpegs;
}

async generatePdf(): Promise<string> {
const filename = this.dir + "/pages.pdf";
const filename = this.dir + "pages.pdf";
const jpegs = await this.getLargeJpegs();
await this.imagesToPdf(jpegs, filename);
if (!fileExists(filename)) {
Expand Down
Loading