Commit a577d438 authored by WorldTeacher's avatar WorldTeacher
Browse files

fix(updater): use correct lfs library path for KOReader

Changed from require("libs/lfs") to require("libs/libkoreader-lfs")
which is the correct path for KOReader's LuaFileSystem library.

Also wrapped in pcall for defensive programming:
- Doesn't crash if lfs unavailable
- Gracefully degrades (file size logging is optional)
- Provides useful debug message as fallback

Fixes error:
  module 'libs/lfs' not found

The file size logging is purely informational and not required
for successful downloads.
parent 6dfac88b
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -558,12 +558,15 @@ function Updater:downloadUpdate(url, progress_callback)
        return false, "HTTP error: " .. tostring(code)
    end
    
    -- Get file size
    local lfs = require("libs/lfs")
    local attr = lfs and lfs.attributes(zip_path)
    if attr then
        total_bytes = attr.size
        logger.info("BookloreSync Updater: Downloaded", total_bytes, "bytes")
    -- Get file size (optional, for logging only)
    local ok, lfs = pcall(require, "libs/libkoreader-lfs")
    if ok and lfs then
        local attr = lfs.attributes(zip_path)
        if attr and attr.size then
            logger.info("BookloreSync Updater: Downloaded", attr.size, "bytes")
        end
    else
        logger.dbg("BookloreSync Updater: Download complete (file size unavailable)")
    end
    
    return true, zip_path