Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

History: update on renaming/moving a folder #10999

Merged
merged 3 commits into from Oct 13, 2023

Conversation

hius07
Copy link
Member

@hius07 hius07 commented Oct 12, 2023

Closes #10995.

(Doesn't update sdr with "dir" setting, but that's another story)


This change is Reviewable

Comment on lines +207 to +209
local file, count = v.file:gsub(old_path, new_path)
if count == 1 then
self.hist[i].file = file
Copy link
Contributor

Choose a reason for hiding this comment

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

About the :gsub(), I guess you should try to match at start, and limit the nb of replacements to 1 (4th parameter, or no need if matching at start).
So sick cases like renaming bits of /mnt/onboard/Library/Fiction/mnt/onboard/Library/myfile.epub are supported :)

@Frenzie Frenzie added this to the 2023.10 milestone Oct 12, 2023
@@ -199,6 +200,22 @@ function ReadHistory:updateItemByPath(old_path, new_path)
end
end

--- Updates the history list after renaming/moving a folder.
function ReadHistory:updateItemsByPath(old_path, new_path)
old_path = "^"..old_path
Copy link
Member

Choose a reason for hiding this comment

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

Oof, this was so confusing to me. I think it'd be much clearer straight in the gsub, heh. :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

straight in the gsub

It's in the loop.

Copy link
Member

Choose a reason for hiding this comment

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

Or old_path_pattern instead of just old_path

@hius07 hius07 merged commit 6ccf19b into koreader:master Oct 13, 2023
3 of 4 checks passed
@hius07 hius07 deleted the history-rename-folder branch October 13, 2023 04:54
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.

Bug: Renaming containing folder using in-app file manager breaks book availability via history
3 participants