Skip to content

use new Archiver module where applicable - #13782

Merged
Frenzie merged 1 commit into
koreader:masterfrom
benoit-pierre:pr/ArchiveViewer_with_libarchive
May 26, 2025
Merged

Frenzie merged 1 commit into
koreader:masterfrom
benoit-pierre:pr/ArchiveViewer_with_libarchive

Conversation

@benoit-pierre

@benoit-pierre benoit-pierre commented May 13, 2025 •

Copy link
Copy Markdown
Member

For more supported formats (only CBR & RAR for now).

Depend on koreader/koreader-base#2086.


This change is Reviewable

@benoit-pierre
benoit-pierre marked this pull request as draft May 13, 2025 23:37
@benoit-pierre
benoit-pierre force-pushed the pr/ArchiveViewer_with_libarchive branch from 14826e9 to d00e93a Compare May 13, 2025 23:46
@hius07

hius07 commented May 14, 2025

Copy link
Copy Markdown
Member

Thank you. Can the libarchive calls be moved to ZipWriter (or new ZipReader or ArcReader), to have simple methods to open, read and extract content of the supported archives?

@hius07

hius07 commented May 14, 2025

Copy link
Copy Markdown
Member

Straightforward ZipWriter calls are beautiful:

local zip = ZipWriter:new{}
zip:open(data_dir .. "/" .. "settings_backup_" .. os.date("%Y-%m-%d %H-%M-%S") .. ".zip")
zip:add("backup", "return " .. dump(backup, nil, true) .. "\n")
zip:close()

@Frenzie Frenzie added this to the 2025.05 milestone May 14, 2025
Comment thread plugins/archiveviewer.koplugin/main.lua Resolved
@benoit-pierre
benoit-pierre force-pushed the pr/ArchiveViewer_with_libarchive branch from d00e93a to 5b8b4e4 Compare May 14, 2025 17:23
@benoit-pierre

Copy link
Copy Markdown
Member Author

Thank you. Can the libarchive calls be moved to ZipWriter (or new ZipReader or ArcReader), to have simple methods to open, read and extract content of the supported archives?

I can in a subsequent PR, but note that the libarchive API is really not suited for random access, even for archives that support it (not solid). Which is why we have to reiterate over the entries in extractContent & extractFile.

MuPDF has similar code, with some minor optimization to only "reset" the state (close & reopen the libarchive handle) when the entry wanted is before the current one.

@benoit-pierre
benoit-pierre marked this pull request as ready for review May 15, 2025 21:06
@hius07

hius07 commented May 16, 2025

Copy link
Copy Markdown
Member

I would like to use it instead of the system unzip in readerui.lua and in the forthcoming back up / restore feature.
Should I copy all that things from this PR?

@hius07

hius07 commented May 16, 2025

Copy link
Copy Markdown
Member

Or we keep unzipping as is and use libarchive for rar only?

@benoit-pierre

Copy link
Copy Markdown
Member Author

I'll make another PR with an ArcReader.

@benoit-pierre

Copy link
Copy Markdown
Member Author

It will still be better than using unzip, especially on Android.

@benoit-pierre
benoit-pierre marked this pull request as draft May 16, 2025 23:59
@benoit-pierre

Copy link
Copy Markdown
Member Author

@hius07: see koreader/koreader-base#2090.

@benoit-pierre
benoit-pierre force-pushed the pr/ArchiveViewer_with_libarchive branch from 5b8b4e4 to d6a6dbe Compare May 24, 2025 21:25
@benoit-pierre benoit-pierre changed the title ArchiveViewer: use libarchive instead of unzip use new Archiver module where applicable May 24, 2025
Comment thread frontend/apps/reader/readerui.lua Resolved
@benoit-pierre
benoit-pierre force-pushed the pr/ArchiveViewer_with_libarchive branch from d6a6dbe to 74f7ce0 Compare May 25, 2025 08:48
@benoit-pierre
benoit-pierre marked this pull request as ready for review May 25, 2025 08:48
@hius07

hius07 commented May 26, 2025

Copy link
Copy Markdown
Member

Looks good, thanks.

Comment thread frontend/device/generic/device.lua Resolved
- ArchiveViewer: instead of using unzip and to support more formats
  (only CBR & RAR for now)
- NewsDownloader & Wikipedia plugins: instead of using `ZipWriter`
- device: re-implement `Device:unpackArchive` and get rid of device
  specific `untar` implementations
- readerui: instead of using unzip for document provider detection
@benoit-pierre
benoit-pierre force-pushed the pr/ArchiveViewer_with_libarchive branch from 74f7ce0 to 9d2b2ac Compare May 26, 2025 14:30
@Frenzie
Frenzie merged commit f63c76d into koreader:master May 26, 2025
@benoit-pierre
benoit-pierre deleted the pr/ArchiveViewer_with_libarchive branch May 26, 2025 14:55
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
- ArchiveViewer: instead of using unzip and to support more formats
  (only CBR & RAR for now)
- NewsDownloader & Wikipedia plugins: instead of using `ZipWriter`
- device: re-implement `Device:unpackArchive` and get rid of device
  specific `untar` implementations
- readerui: instead of using unzip for document provider detection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants