05-30-2018, 05:47 PM | #1 |
Wizard
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Bug (Crash): Replace File Capitalization
I have attached an EPUB + XHTML file to show the problem.
Problem If the EPUB has a filename: Code:
Thisisacover.xhtml (capital T) Code:
thisisacover.xhtml (lowercase T) Steps to Reproduce 1. Open EPUB. 2. Right Click + Add Existing Files, and add thisisacover.xhtml to EPUB. Versions Tested Latest Sigil 0.9.9 on Windows 10 and Mac High Sierra (10.13.4). * * * * * Other Replace File Issue If you use Add Existing Files to replace files that already exist in the ePUB: If it reaches an image file, you get: Code:
The multimedia file "filename.jpg" already exists in the book. OK to replace? OK + Cancel But with an HTML file you get: Code:
Unable to load "filename.xhtml" A file with this name already exists in the book. OK It would be helpful if:
Currently, it is frustrating if you try to replace a lot of files and have to click through them one-by-one. |
05-30-2018, 06:04 PM | #2 |
Groupie
Posts: 171
Karma: 3517858
Join Date: May 2016
Location: Monterrey, Mexico
Device: Samsung Tab-3 7"
|
Oh, my! It certainly does! I quickly ginned up a little practice session, and it did just as you say.
As far as your second scenario, the same occurs with the stylesheet.css, and any external fonts. IMHO, this is more of a protection than a problem. |
Advert | |
|
05-30-2018, 07:15 PM | #3 | |
Wizard
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
I plop template files into the EPUB. Many times, the old EPUB has the same common filenames. If there was a conflict, then you should be able to overwrite/skip (just like you currently can with images). Currently, you have to remember which HTML files were conflicts, then manually delete them out of your book, then readd the template files all over again. Most of the time, I only notice the title page wasn't overwritten until quality checking, and then it's just easier for me to copy/paste code instead of using the Add Existing Files functionality. This becomes quite the pain when the amount of replaced files becomes large. |
|
05-30-2018, 08:11 PM | #4 |
Sigil Developer
Posts: 7,506
Karma: 5433350
Join Date: Nov 2009
Device: many
|
Travelling but I will create a fix upon my return. The problem is my OSX dev machine uses a case sensitive file system (an advanced option on Macs) and therefore no crash. I will add an external hard drive with a case insensitive file system to recreate the crash.
|
05-30-2018, 09:36 PM | #5 |
Sigil Developer
Posts: 7,506
Karma: 5433350
Join Date: Nov 2009
Device: many
|
Took a look and the file name being added is compared to a list and if it is not contained in the list of existing files, it is added. The filenames.contains() test in the AddExisting code needs to add the Qt:CaseInsensitive flag.
I will push this change to master to prevent any crash. |
Advert | |
|
05-31-2018, 08:26 AM | #6 |
Sigil Developer
Posts: 7,506
Karma: 5433350
Join Date: Nov 2009
Device: many
|
Also, #2 not a big issue if you load template ePub first and only load non-template files from old ePub. This is even easier if you preface your template ePub files with names indicating their source (preface filenames with template or temp or std or ...).
Replacing multiple possibly linked in html can result in lost footnotes, orphan images, orphan multi-media. Using global rename on the old ePub in Sigil before merging should also work. |
05-31-2018, 09:14 AM | #7 | |
Groupie
Posts: 171
Karma: 3517858
Join Date: May 2016
Location: Monterrey, Mexico
Device: Samsung Tab-3 7"
|
Quote:
I have a--probably irrational--aversion to adding garbage code to my epub, so I create the new book basically from scratch, pulling in my template pages; then, from the original e-pub, I copy/paste only the body text into my template page, making sure not to include anything from above the <body> element. Also, normally I only need to copy from/to one page, as I have merged all the actual text into one file after placing a Sigil chapter break where I'm going to want a separation. Kinda getting off topic here, though. This maybe would be more appropriate in the workshop forum. But maybe this'll help you avoid some of those issues. Meanwhile, I notice that Kevin has jumped on the real issue in his normal prompt fashion, so thanks for that, K! Some of the weirdest issues crop up from supporting software on such wildly divergent platforms! |
|
05-31-2018, 01:32 PM | #8 | ||
Wizard
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Can't wait!
Thanks for hunting down the bug and the quick fix. I wonder if there are any other related case-sensitive bugs lurking in there? What if an external program created an EPUB that gets loaded into Sigil, and it has both Copyright.xhtml + copyright.xhtml? I forget, do the EPUB specs specify filenames being case-sensitive? Quote:
But it's how we all get better at making books and make Sigil better overall. I'm pretty excited because I recently brought a completely new Sigil user aboard. And she's looking at the program with completely fresh eyes. When she caused Sigil to crash because of this capitalization bug, I was thinking: "Eh? It's been stable for so long. What did you do wrong?" Sometimes when we've been using the programs for so long, we get used to doing it way A or using workarounds XYZ, and become completely blind to way B. Quote:
I imagine it being like a Save As prompt: You get a popup: "That filename already exists. Are you sure you want to overwrite?" Yes. Where the current functionality is like: "That filename already exists." And the only choice is to say "Yes, I know. Yes, I know" over and over and over again until it goes away. Global Rename is also not the best of solutions. Imagine a book full of filenames like this (HTML articles pulled from a site): - titlepage.html - copyright.html - The Guatemalan Economic Miracle and the Man Who Helped It Happen.html - Adam Heydel, A Mises Student From Poland.html - A Chinese Gentleman and the Conscience of a Generation.html - [...] They are already organized in a certain chapter order in the current EPUB. Case A You are trying to replace with alternate versions. If you were able to just Add Existing + be able to overwrite, this would be no problem. And the chapter order stays completely in tact. (You could also Skip All and retain current functionality.) Case B (KevinH) If you mass rename the files in the current EPUB, you completely lose the information of the filenames: - titlepage.html - copyright.html - Chapter01.html - Chapter02.html - Chapter03.html (or you can manually rename each file individually to TRY to keep a similar name [appending "-2" to the end]. The more files there are, the more time this takes.) Now when you add the new files: - titlepage.html - copyright.html - Chapter01.html - Chapter02.html - Chapter03.html - A Chinese Gentleman and the Conscience of a Generation.html - Adam Heydel, A Mises Student From Poland.html - The Guatemalan Economic Miracle and the Man Who Helped It Happen.html Now you have to drag/drop the new chapters into their old positions, and/or figure out "Chapter02.html" <-> "Adam Heydel, A Mises Student From Poland.html". Then delete the "Chapter02.html" file. The more files there are, the more of a pain point this becomes. Case C (JustinThought) New EPUB. Insert new files. I sometimes do this too, but the biggest disadvantage is you lose the order of the chapters. When you add in files, it inserts them all alphabetically, so you might get something like this: - A Chinese Gentleman and the Conscience of a Generation.html - Adam Heydel, A Mises Student From Poland.html - copyright.html - The Guatemalan Economic Miracle and the Man Who Helped It Happen.html - titlepage.html - [...] Now you have to manually move the chapters around again. Case D/E I know I know, this is getting in the weeds, but there are two other potential workarounds:
ORRRRRRRRRRRRRRRR we could just go with the genius that is Case A. Last edited by Tex2002ans; 05-31-2018 at 01:35 PM. |
||
06-03-2018, 11:20 PM | #9 | |
Groupie
Posts: 171
Karma: 3517858
Join Date: May 2016
Location: Monterrey, Mexico
Device: Samsung Tab-3 7"
|
Quote:
|
|
06-04-2018, 10:39 AM | #10 |
Sigil Developer
Posts: 7,506
Karma: 5433350
Join Date: Nov 2009
Device: many
|
Just pushed fix for crash to master. I will not add the capability to replace single or multiple existing html files at once due to issues with renaming when not an exact match but only a match due to case insensitive filesystems. Renaming even one of a set will/can break links to other html files, toc, etc, etc,
So the solution to wanting anything else is to: 1. keep a template epub with your template files in which all filenames in the template have a unique prefix. Or 2. load epub to be merged first and rename conflicting files so that Sigil can properly handle updating and correcting all links before merging into first epub. 3. write an edit plugin that groks your template system and have it load the files and fix any broken links BTW, this bug may still cause issues with similarly6 named multimedia or images as I do not yet have a case insensitive filesystem to check with (yet). My focus was on preventing the initial crash. |
06-04-2018, 11:34 AM | #11 |
Sigil Developer
Posts: 7,506
Karma: 5433350
Join Date: Nov 2009
Device: many
|
BTW, just for the record uri's and url's have case insensitive schemes and host names but navigation info after that is recommended to be case sensitive.
Ebook readers and ebook reading software may decide to use either case-sensitive or case-insenstive file systems and there is no way for an epub to know which type of device it is stored on when opened. Therefore any use of just upper or lower case or a mix of cases to distinguish between files names in an epub is a big mistake on the epub developer's part, as the epub's opf uri and all links are supposed to be case-sensitive. So I can not just "replace" a "myimage.jpg" with "MyImage.jpg" as the opf manifest url will be incorrect, and img tag urls will be incorrect, etc. This is true on a case-senstiive filesystem as well as a case-insensitive filesystem since the uri's after the host are supposed to be case sensitive. So although I prevented the reported crash with my last fix, trying to replace an myimage.jpg with a MyImage.jpg will fail in all cases. The problem only gets worse with buik replacement of mixed case file names. So again, the best way to handle this situation is to fix filenames inside Sigil before trying to merge two epubs as this is the only way to assure links/uris are properly updated. Last edited by KevinH; 06-04-2018 at 12:34 PM. |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Bug? No --search-replace processing in Windows | TechnoCat | Conversion | 3 | 06-12-2017 11:28 AM |
Open Video File Crash | BetterRed | Sigil | 41 | 04-23-2016 08:21 PM |
find replace bug? | cybmole | Sigil | 14 | 11-07-2012 01:17 AM |
Search and Replace - possible bug? | PL_kolek | Conversion | 2 | 11-01-2012 06:56 AM |
Find/Replace bug? | bfollowell | Sigil | 14 | 05-19-2012 01:14 PM |