Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

Fix encrypted PDF unlock modal missing on IndexedDB restore and large files (#6099)

plind4ada46ca567c
diff --git a/frontend/src/core/contexts/file/fileActions.ts b/frontend/src/core/contexts/file/fileActions.ts
index ac6d71d691..2c571d3c70 100644
--- a/frontend/src/core/contexts/file/fileActions.ts
+++ b/frontend/src/core/contexts/file/fileActions.ts
@@ -391,8 +391,15 @@ export async function addFiles(
let thumbnail: string | undefined;
if (targetFile.type.startsWith("application/pdf")) {
- processedFileMetadata = await generateProcessedFileMetadata(targetFile);
- thumbnail = processedFileMetadata?.thumbnailUrl;
+ if (fileStub.processedFile?.isEncrypted) {
+ // Pre-dispatch detection already flagged this PDF as encrypted; PDF.js
+ // can't produce thumbnails/metadata without the password, so re-parsing
+ // here would just duplicate work. Metadata is refreshed after unlock.
+ processedFileMetadata = fileStub.processedFile;
+ } else {
+ processedFileMetadata = await generateProcessedFileMetadata(targetFile);
+ thumbnail = processedFileMetadata?.thumbnailUrl;
+ }
} else {
try {
const { generateThumbnailForFile } = await import("@app/utils/thumbnailUtils");