MCPcopy Create free account
hub / github.com/pacexy/flow / handleFiles

Function handleFiles

apps/reader/src/file.ts:14–41  ·  view source on GitHub ↗
(files: Iterable<File>)

Source from the content-addressed store, hash-verified

12}
13
14export async function handleFiles(files: Iterable<File>) {
15 const books = await db?.books.toArray()
16 const newBooks = []
17
18 for (const file of files) {
19 console.log(file)
20
21 if (mapExtToMimes['.zip'].includes(file.type)) {
22 unpack(file)
23 continue
24 }
25
26 if (!mapExtToMimes['.epub'].includes(file.type)) {
27 console.error(`Unsupported file type: ${file.type}`)
28 continue
29 }
30
31 let book = books?.find((b) => b.name === file.name)
32
33 if (!book) {
34 book = await addBook(file)
35 }
36
37 newBooks.push(book)
38 }
39
40 return newBooks
41}
42
43export async function addBook(file: File) {
44 const epub = await fileToEpub(file)

Callers 3

ReaderGroupFunction · 0.90
IndexFunction · 0.90
LibraryFunction · 0.90

Calls 3

unpackFunction · 0.90
addBookFunction · 0.85
findMethod · 0.45

Tested by

no test coverage detected