Skip to content

Commit

Permalink
fix: allow PDF files in zip uploads
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Alemayhu <alexander@alemayhu.com>
  • Loading branch information
aalemayhu committed Jan 2, 2025
1 parent 7da3577 commit a855e4a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/lib/zip/zip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
isHTMLFile,
isImageFile,
isMarkdownFile,
isPDFFile,
} from '../storage/checks';
import { processAndPrepareArchiveData } from './fallback/processAndPrepareArchiveData';
import CardOption from '../parser/Settings';
Expand Down Expand Up @@ -95,7 +94,7 @@ class ZipHandler {
paying: boolean,
settings: CardOption
) {
if (name.includes('__MACOSX/') || isPDFFile(name)) return;
if (name.includes('__MACOSX/')) return;

if (name.endsWith('.zip')) {
this.zipFileCount++;
Expand Down
3 changes: 0 additions & 3 deletions src/usecases/uploads/getPackagesFromZip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ export const getPackagesFromZip = async (

let cardCount = 0;
for (const fileName of fileNames) {
/**
* XXX: Should we also support files without extensions?
*/
if (isZipContentFileSupported(fileName)) {
const deck = await PrepareDeck({
name: fileName,
Expand Down
9 changes: 5 additions & 4 deletions src/usecases/uploads/isZipContentFileSupported.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import {
isXLSXFile,
} from '../../lib/storage/checks';

/**
* XXX: Should we also support files without extensions?
*/
const isFileWithoutExtension = (filename: string) =>
filename && filename.indexOf('.') === -1;

export const isZipContentFileSupported = (filename: string) =>
isHTMLFile(filename) ??
isMarkdownFile(filename) ??
isPlainText(filename) ??
isCSVFile(filename) ??
isPDFFile(filename) ??
isXLSXFile(filename);
isXLSXFile(filename) ??
isFileWithoutExtension(filename);

0 comments on commit a855e4a

Please sign in to comment.