Verified Commit 56865063 authored by WorldTeacher's avatar WorldTeacher
Browse files

fix(menu): remove double reading status entry, update makefile

parent c0ec5230
Loading
Loading
Loading
Loading

.coderabbit.yml

deleted100644 → 0
+0 −7
Original line number Diff line number Diff line
reviews:
  auto_review:
    enabled: true
    drafts: false
    base_branches:
      - main
      - develop
+5 −2
Original line number Diff line number Diff line
SHELL := /usr/bin/env bash

.PHONY: test documentation
.PHONY: test documentation version

test:
	./run_tests.sh

documentation:
	cd docs && zola serve

version:
	uv run ~/.scripts/next_version.py
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -546,7 +546,7 @@ function M.new(deps)

            -- ── Check disk space before downloading ─────────────────────────────
            if not already_exists then
                local file_size, size_err = self.api:getBookFileSize(book_id, self.username, self.password)
                local file_size, size_err = self.api:getBookFileSize(book_id, self.booklore_username, self.booklore_password)
                if not file_size then
                    self:logWarn("BookloreSync: could not get file size for book", book_id, ":", size_err or "unknown error")
                else
+1 −9
Original line number Diff line number Diff line
@@ -991,7 +991,7 @@ function BookloreSync:init()
            },
        }
    end)
    -- Row 3: tracking + status actions
    -- Row 3: tracking toggle (full width)
    FileManager.addFileDialogButtons(FileManager, "booklore_sync_actions_row3", function(file, is_file, _book_props)
        if not is_file then return nil end
        return {
@@ -1008,14 +1008,6 @@ function BookloreSync:init()
                    self:fileDialogToggleTracking(file)
                end,
            },
            {
                text = _("Set Reading Status"),
                callback = function()
                    local fc = FileManager.instance and FileManager.instance.file_chooser
                    if fc and fc.file_dialog then UIManager:close(fc.file_dialog) end
                    self:fileDialogSetReadingStatus(file)
                end,
            },
        }
    end)
    -- Row 4: reading status (full width)
+82 −0
Original line number Diff line number Diff line
@@ -1077,4 +1077,86 @@ describe("BookloreSync:syncFromBookloreShelf", function()
    assert.is_false(p.sync_in_progress)
  end)

  it("uses Booklore credentials for file-size preflight", function()
    package.preload["libs/libkoreader-lfs"] = function()
      return make_lfs_stub({ files = {} })
    end
    package.preload["booklore_api_client"] = function()
      return make_api_stub({
        books = {
          { id = 21, title = "CredCheck", extension = "epub" },
        },
        download_ok = true,
      })
    end
    package.preload["booklore_database"] = function()
      return make_db_stub({ shelf_state = nil })
    end

    local p = make_plugin({
      username = "koreader-user",
      password = "koreader-pass",
      booklore_username = "booklore-user",
      booklore_password = "booklore-pass",
      min_free_space_mb = 500,
    })

    local got_username, got_password
    p.api.getBookFileSize = function(_, _, username, password)
      got_username = username
      got_password = password
      return 1024, nil
    end
    p.getAvailableSpace = function()
      return 1024 * 1024 * 1024, nil
    end

    p:syncFromBookloreShelf(true)

    assert.are.equal("booklore-user", got_username)
    assert.are.equal("booklore-pass", got_password)
    assert.is_false(p.sync_in_progress)
  end)

  it("does not save shelf state when sync stops for insufficient disk space", function()
    package.preload["libs/libkoreader-lfs"] = function()
      return make_lfs_stub({ files = {} })
    end
    package.preload["booklore_api_client"] = function()
      return make_api_stub({
        books = {
          { id = 31, title = "BigBook", extension = "epub" },
        },
        download_ok = true,
      })
    end
    package.preload["booklore_database"] = function()
      return make_db_stub({ shelf_state = nil })
    end

    local p = make_plugin({ min_free_space_mb = 500 })
    p.api.getBookFileSize = function()
      return 100 * 1024 * 1024, nil
    end
    p.getAvailableSpace = function()
      return 50 * 1024 * 1024, nil
    end

    local shelf_state_saved = false
    p.db.saveShelfState = function()
      shelf_state_saved = true
    end

    local callback_ok, callback_msg
    p:syncFromBookloreShelf(true, function(ok, msg)
      callback_ok = ok
      callback_msg = msg
    end)

    assert.is_false(shelf_state_saved)
    assert.is_false(callback_ok)
    assert.is_truthy(callback_msg)
    assert.is_false(p.sync_in_progress)
  end)

end)