Skip to content

Commit 052203e

Browse files
committed
Fix integration test
1 parent 33dde05 commit 052203e

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/hooks/custom/SplitPdfHook.ts

+8-12
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,6 @@ export class SplitPdfHook
118118

119119
let pagesCount = pageRangeEnd - pageRangeStart + 1;
120120

121-
if (pagesCount < MIN_PAGES_PER_THREAD) {
122-
console.info(
123-
`PDF has less than ${MIN_PAGES_PER_THREAD} pages. Partitioning without split.`
124-
);
125-
return request;
126-
}
127121

128122
const startingPageNumber = getStartingPageNumber(formData);
129123
console.info("Starting page number set to %d", startingPageNumber);
@@ -137,14 +131,16 @@ export class SplitPdfHook
137131
const splitSize = await getOptimalSplitSize(pagesCount, concurrencyLevel);
138132
console.info("Determined optimal split size of %d pages.", splitSize)
139133

140-
// If the doc is small enough, and we aren't slicing it with a page range:
141-
// do not split, just continue with the original request
142-
if (splitSize >= pagesCount && pagesCount == totalPages) {
143-
console.info(
134+
// If we aren't requesting a slice of the pdf, i.e. the page range covers the total page count
135+
// and if the doc is small enough, do not split, just continue with the original request
136+
if (pagesCount == totalPages) {
137+
if (splitSize >= pagesCount || pagesCount < MIN_PAGES_PER_THREAD) {
138+
console.info(
144139
"Document has too few pages (%d) to be split efficiently. Partitioning without split.",
145140
pagesCount,
146-
)
147-
return request;
141+
)
142+
return request;
143+
}
148144
}
149145

150146
const splits = await splitPdf(pdf, splitSize, pageRangeStart, pageRangeEnd);

0 commit comments

Comments
 (0)