Skip to content

Fix wallabag directories' trailing slashes#14001

Merged
Frenzie merged 3 commits into
koreader:masterfrom
harmtemolder:fix
Jun 30, 2025
Merged

Fix wallabag directories' trailing slashes#14001
Frenzie merged 3 commits into
koreader:masterfrom
harmtemolder:fix

Conversation

@harmtemolder

@harmtemolder harmtemolder commented Jun 29, 2025

Copy link
Copy Markdown
Contributor

Fixes #13987

Also added to onetime_migration.lua to add the trailing slashes so users do not need to manually choose the dir again for this fix to apply.

This change is Reviewable

@harmtemolder harmtemolder changed the title Fix wallabag trailing slashes #13987 Fix wallabag directories' trailing slashes Jun 29, 2025
@Frenzie Frenzie added this to the 2025.06 milestone Jun 29, 2025
@harmtemolder

Copy link
Copy Markdown
Contributor Author

I've tested on my Kobo, there it works

@Frenzie

Frenzie commented Jun 29, 2025

Copy link
Copy Markdown
Member

I'm not entirely sure if that makes sense in the context of the rest of the code. I think that everywhere else it's path .. "/" .. filename where it's used. What do you think @hius07?

@Frenzie Frenzie added the Plugin label Jun 29, 2025
@hius07

hius07 commented Jun 29, 2025

Copy link
Copy Markdown
Member

Usually we store dir paths without the trailing slash.

@Frenzie

Frenzie commented Jun 29, 2025

Copy link
Copy Markdown
Member

In that case @harmtemolder would you mind changing it to add the / in the concatenation where it's used? Sorry to bother you but then it's congruent with code elsewhere and we can also avoid adding a whole migration. :-)

@harmtemolder harmtemolder marked this pull request as draft June 29, 2025 14:24
@harmtemolder

Copy link
Copy Markdown
Contributor Author

Sure thing. I'm all for staying congruent with code elsewhere. We still need the migration though, because when using the default before (instead of manually selecting a directory) this would include the trailing slash.

I believe I've now rewritten everything to not store trailing slashes in settings, and to concatenate it in when using self.directory or self.archive_directory. I'm testing that now.

Comment thread frontend/ui/data/onetime_migration.lua Outdated
local wb_lua = DataStorage:getSettingsDir() .. "/wallabag.lua"
if lfs.attributes(wb_lua, "mode") == "file" then
local wb_settings = LuaSettings:open(wb_lua)
wb_settings:readSetting("wallabag")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do

local settings = wb_settings:readSetting("wallabag")

you can use shorter settings.directory and avoid saveSettings later.

Comment thread frontend/ui/data/onetime_migration.lua Outdated
local wb_settings = LuaSettings:open(wb_lua)
wb_settings:readSetting("wallabag")

if wb_settings.data.wallabag.directory:sub(-1) == "/" then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the check is not needed, gsub does all the work.

@Frenzie

Frenzie commented Jun 29, 2025

Copy link
Copy Markdown
Member

We still need the migration though, because when using the default before (instead of manually selecting a directory) this would include the trailing slash.

Unlike the reverse I don't think that's actually problematic other than looking a bit silly? Don't just take my word for it of course, but:

$ touch bla
$ mkdir lala
$ mv bla lala///bla
$ cd lala/
$ ls
bla

@harmtemolder

Copy link
Copy Markdown
Contributor Author

I found ffi/util.joinPath() and noticed that ffi/util was already used in main.lua, so figured it would be cleanest to use that. So:

  • From now on manually set self.directory or self.archive_directory will not have a trailing slash.
  • From now on the default self.archive_directory will not have a trailing slash. (self.directory does not have a default.)
  • Users that still have either with a trailing slash in their settings will not notice any change, because ffi/util.joinPath() handles both cases.

And no migration is needed.

@harmtemolder harmtemolder marked this pull request as ready for review June 30, 2025 06:09

@Frenzie Frenzie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me.

@Frenzie Frenzie requested a review from hius07 June 30, 2025 07:07
@Frenzie Frenzie merged commit 7d89cb2 into koreader:master Jun 30, 2025
4 checks passed
@harmtemolder harmtemolder deleted the fix branch June 30, 2025 09:05
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wallabag Move to archive folder instead of deleting path doesn't use a trailing /

3 participants