Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 04-06-2024, 09:31 PM   #16
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,553
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Works for me on Windows. OPF properly updated.
DiapDealer is offline   Reply With Quote
Old 04-06-2024, 09:43 PM   #17
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,661
Karma: 5433388
Join Date: Nov 2009
Device: many
Great!

So if this works on Linux too, I can try to track down where else in "move" and "restructure code" changes might also be needed.
KevinH is online now   Reply With Quote
Advert
Old 04-06-2024, 09:49 PM   #18
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,553
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I'm afraid I'm getting no joy on Linux with the same patch. I've double-checked that the patch has been applied and that I'm running the version of Sigil I just rebuilt.
DiapDealer is offline   Reply With Quote
Old 04-06-2024, 10:00 PM   #19
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,661
Karma: 5433388
Join Date: Nov 2009
Device: many
Oh well! Time to rethink that approach then. I really do not want to get into testing filesystems for case insensitive or not.

Let me think about how that routine should work on a true case sensitive filesystem.
KevinH is online now   Reply With Quote
Old 04-06-2024, 10:05 PM   #20
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,661
Karma: 5433388
Join Date: Nov 2009
Device: many
I think that this logic must be changed depending on filesystem type:

Code:
if (existing_bookpaths.contains(proposed_bookpath, Qt::CaseInsensitive))
But that would require knowing both source and destination filesystem case sensitivities which I do not want to do.

So maybe just a simple file exists() test would be better than a case insensitive search of existing bookpaths.

On a case sensitive filesystem, file exists() should return false for just a case change (assuming another file did not already exist with that case variant).

On a case insensitive filesystem, file exists() should return true for just a case change (and other case variants can not co-exist).

Yes, that should work on all filesystems without having to know which we are on

I will play around more tomorrow to test that approach.

Last edited by KevinH; 04-06-2024 at 10:17 PM.
KevinH is online now   Reply With Quote
Advert
Old 04-06-2024, 10:07 PM   #21
AlanHK
Guru
AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.
 
AlanHK's Avatar
 
Posts: 668
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
I do like to have consistent filenames. Mostly all lower case as removes case issues. I learnt to make case changes in two steps, add a letter, change case and delete the letter.

I had a few problems previously when the epub had a file "image.jpg" and I import a better one "Image.jpg" that replaces the old version. This displays fine in Windows and in Sigil. Convert to AZW3 is fine. But sending the file to an iPad, no image.

Eventually did an epubcheck and it told me "image.jpg" was missing. Perplexed until I finally noticed the case. Now aware of this and compulsively do epubchecks on my files, especially before sending anywhere.

Probably impossible, but would be nice if Sigil was strict about name cases regardless of OS. e.g. did not display an image if the filename case does not match the code.
AlanHK is offline   Reply With Quote
Old 04-06-2024, 10:22 PM   #22
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,661
Karma: 5433388
Join Date: Nov 2009
Device: many
Unfortunately, on a case insensitive filesystem all img src urls with just case variants will show the file as being there. There is no way to prevent that on systems like Windows.

That is why epubcheck is needed to check that the exact case of the manifest url for that file matches in a case sensitive manner with the url.
KevinH is online now   Reply With Quote
Old 04-07-2024, 11:16 AM   #23
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,661
Karma: 5433388
Join Date: Nov 2009
Device: many
Okay, here is an updated version that tries to be as fast (accessing file info on filesystems can be quite slow) as possible, but still work on Linux, MacOS, and Windows.

Code:
diff --git a/src/MainUI/OPFModel.cpp b/src/MainUI/OPFModel.cpp
index 3e9e7715f..59988d6a0 100644
--- a/src/MainUI/OPFModel.cpp
+++ b/src/MainUI/OPFModel.cpp
@@ -765,10 +765,21 @@ bool OPFModel::FilenameIsValid(const QString &old_bookpath, const QString &new_f
     QString sdir = Utility::startingDir(old_bookpath);
     QString proposed_bookpath = sdir.isEmpty() ? new_filename : sdir + "/" + new_filename;
     const QStringList existing_bookpaths = m_Book->GetFolderKeeper()->GetAllBookPaths();
+    // Using QFileInfo is slow so pretest with a much faster method before using it
     if (existing_bookpaths.contains(proposed_bookpath, Qt::CaseInsensitive)) {
-        Utility::DisplayStdErrorDialog(
-            tr("The filename \"%1\" is already in use.\n").arg(new_filename));
-        return false;
+        // potential issue on filesystems that are case insensitive
+        QString FullPathToMainFolder = m_Book->GetFolderKeeper()->GetFullPathToMainFolder();
+        QString orig_full_path = FullPathToMainFolder + "/" + old_bookpath;
+        QString proposed_full_path = FullPathToMainFolder + "/" + proposed_bookpath;
+        if (QFileInfo::exists(proposed_full_path)) {
+            // return false if orig_full_path and proposed_full_path are different files
+            // but allow through case only variationss from case insensitive filesystems
+            if (QFileInfo(orig_full_path) != QFileInfo(proposed_full_path)) {
+                Utility::DisplayStdErrorDialog(
+                    tr("The filename \"%1\" is already in use.\n").arg(new_filename));
+                return false;
+            }
+        }
     }
     return true;
 }

Please someone give this new version a try on Linux and Windows. It works on MacOS.

Thanks
KevinH is online now   Reply With Quote
Old 04-07-2024, 11:26 AM   #24
BeckyEbook
Guru
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
Posts: 692
Karma: 2180740
Join Date: Jan 2017
Location: Poland
Device: Misc
Works on Windows.
Changes Cover.xhtml to cover.xhtml without any problems
However, if I already have the name Cover.xhtml then the other file cannot be named cover.xhtml
BeckyEbook is offline   Reply With Quote
Old 04-07-2024, 11:29 AM   #25
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,661
Karma: 5433388
Join Date: Nov 2009
Device: many
Update:

I was able to get my Manjaro linux box up and ran this test and now it works on Linux.

If this works on Windows, then I can try to track down where else changes are needed.

Thanks,

Last edited by KevinH; 04-07-2024 at 11:43 AM.
KevinH is online now   Reply With Quote
Old 04-07-2024, 11:31 AM   #26
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,661
Karma: 5433388
Join Date: Nov 2009
Device: many
Quote:
Originally Posted by BeckyEbook View Post
Works on Windows.
Changes Cover.xhtml to cover.xhtml without any problems
However, if I already have the name Cover.xhtml then the other file cannot be named cover.xhtml
I am not sure I understand.

You can change Cover.xhtml to cover.xhtml but can not then change cover.xhtml back to Cover.xhtml?

Or do you mean you have two files named "Cover.xhtml" but in different folders?

On Windows you can not have two files in the same folder that are just variants in case. But renaming a single file should now work even if just a case variant.

So I am confused.

The problem is Linux will allow two case variants of the same name in the same folder, but this is a horrible idea for epubs to do since many e-reader filesystems use FAT and desktop users use MacOS and Windows which are case insensitive.

Our earlier code explicitly prevented that and still should even after this change.

Last edited by KevinH; 04-07-2024 at 11:51 AM.
KevinH is online now   Reply With Quote
Old 04-07-2024, 11:50 AM   #27
BeckyEbook
Guru
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
Posts: 692
Karma: 2180740
Join Date: Jan 2017
Location: Poland
Device: Misc
No, no...
I have a file named cover.xhtml and when ANOTHER file I want rename to Cover.xhtml – then I can't do it and VERY well.
Attached Thumbnails
Click image for larger version

Name:	sigil-try-two-cover-filenames.png
Views:	23
Size:	10.0 KB
ID:	207407  
BeckyEbook is offline   Reply With Quote
Old 04-07-2024, 11:54 AM   #28
BeckyEbook
Guru
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
Posts: 692
Karma: 2180740
Join Date: Jan 2017
Location: Poland
Device: Misc
This is possible:
Attached Thumbnails
Click image for larger version

Name:	sigil-the-same-names-different-folders.png
Views:	23
Size:	2.6 KB
ID:	207408  
BeckyEbook is offline   Reply With Quote
Old 04-07-2024, 11:57 AM   #29
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,661
Karma: 5433388
Join Date: Nov 2009
Device: many
Okay that is good!

My problem is going to be when renames are done in large groups and two different files try to end up with differnt names but that are case variants only.

As long as I do the renaming one file at a time, this new approach will work since the QFileInfo.exists(path) will work but to pre-approve a group of files to be renamed (without renaming them one by one for speed reasons) I must now change things to make sure that in a case insensitive manner no collisions will occur in the complete set.

Last edited by KevinH; 04-07-2024 at 12:43 PM.
KevinH is online now   Reply With Quote
Old 04-07-2024, 11:58 AM   #30
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,661
Karma: 5433388
Join Date: Nov 2009
Device: many
Quote:
Originally Posted by BeckyEbook View Post
This is possible:
Yes, and that should always work as the bookpaths are unique.

Good to know.
KevinH is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
case-sensitive search ? Jacques Q. Library Management 1 04-02-2024 05:15 PM
Case sensitive sort Karellen Editor 2 03-14-2023 07:09 PM
[Feature Request] - Enable wikipedia after the BBB filter is enabled. Lenorav Kindle Developer's Corner 2 11-12-2014 03:02 AM
Case-sensitive search john_es Calibre 1 02-18-2014 12:25 AM
K3 search case sensitive only? charonme Amazon Kindle 1 01-28-2011 05:15 PM


All times are GMT -4. The time now is 01:43 PM.


MobileRead.com is a privately owned, operated and funded community.