![]() |
#1 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Dec 2022
Location: in UTC+1 TZ
Device: PocketBook Touch Lux 4
|
Ebook editor silently overwrites read-only ebook files
I've been using linux version of Calibre's ebook editor for years, since version 3.x I think. I really like it, all the progress it made, but there's this one thing I can't (under)stand: when saving, it silently overwrites read-only ebook files. The read-only attribute is there for a purpose you know, you should at least get a warning about the file being write-protected and a chance to back off…
Last time it worked well enough was in version 5.36 -- when you clicked 'save' you got an error message that the file could not be saved, so you knew you might had done something you didn't want to do. Since 5.37 there's no more message and the file just gets silently overwritten despite being protected -- in theory -- by its read-only attribute. I thought that maybe this was just a new bug and would be fixed soon but there were already more than 10 releases since 5.36 and it still does that. I tried to be careful about it but since I frequently have several editor windows open I've already got bitten by it several times -- I modified and saved wrong ebook files effectively losing large parts of them. So, am I the only one who finds overwriting of read-only files without any warning unacceptable? Is this a “feature” of this editor or indeed a bug? |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,349
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Why are you even editing read only files? what is it you hope to achieve by doing that? Editing a file that you dont want changed is well...
And this was a deliberate feature, introduced in 5.37 which you can see in https://calibre-ebook.com/whats-new And it was introduced precisely to prevent someone from losing hours of work if they happen to edit a file that was readonly for a random reason and they dont know how to fix file permissions (which is surprisingly common). And yes there could be a warning dialog, but implementing one is too much effort for this, at least for me, patches welcome. |
![]() |
![]() |
![]() |
#3 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,349
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
On second thoughts, its much easier to show the warning once when the book is opened. https://github.com/kovidgoyal/calibr...523a7869c8c518
|
![]() |
![]() |
![]() |
#4 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,755
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
![]() |
![]() |
![]() |
#5 | |
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 167
Karma: 1497966
Join Date: Jul 2021
Device: N/A
|
Quote:
I don't know if I understand the code of your present patch correctly, but it seems that you've put a warning, but no option to desist. Am I right ? If it's the case, I think it would be welcome to be able to desist, and to "save as" instead. Last edited by lomkiri; 12-21-2022 at 03:11 PM. |
|
![]() |
![]() |
![]() |
#6 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,755
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
![]() |
![]() |
![]() |
#7 | |
Still reading
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 14,033
Karma: 105092227
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
|
Quote:
Only pressed CDs, DVDs, ROMs and similar are immutably Read Only. |
|
![]() |
![]() |
![]() |
#8 | |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,725
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Quote:
BR |
|
![]() |
![]() |
![]() |
#9 | |||
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 167
Karma: 1497966
Join Date: Jul 2021
Device: N/A
|
Quote:
Anyway, if I may give my advice, it's not an expected behavior to change the RW rights when we want to write on a protected file, and I guess that's what Falsifier is complaining about. If a book have been put in RO, calibre shouldn't overpass this decision, he could, maybe, only save after a warning, but without changing the permission (as vim do). In fact, the expected behavior, IMO, would be to deny "save" on a RO only file, maybe with a warning saying why and suggesting either to change the perms or to "save a copy". But I guess it's not an easy task in the code (I understand that "save" and "save a copy" use the same method applied on different paths, so maybe it's not that simple to have a different behavior for one or for the other). Quote:
Quote:
Last edited by lomkiri; 12-21-2022 at 05:32 PM. |
|||
![]() |
![]() |
![]() |
#10 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,725
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
This is on Windows
When I do a Save As, it defaults to the location used for the previous Save As. However, if that location no longer exists it uses it's parent, and if that location doesn't exist it uses it's parent . . . but that can end up in a location where the current user doesn't have write permission - e.g. the Users directory. If you try to save in that location Windows will tell you that you can't do that, and offer to do the save to your home directory. BR Last edited by BetterRed; 12-21-2022 at 08:21 PM. |
![]() |
![]() |
![]() |
#11 | ||
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Dec 2022
Location: in UTC+1 TZ
Device: PocketBook Touch Lux 4
|
Quote:
Quote:
Code:
--- calibre-6.10.0/src/calibre/gui2/tweak_book/save.py.6.10.0.orig 2022-12-16 03:29:36.000000000 +0100 +++ calibre-6.10.0/src/calibre/gui2/tweak_book/save.py 2022-12-23 23:01:01.483650018 +0100 @@ -48,7 +48,16 @@ raise # Somebody deleted the original file + if st is not None: + try: + os.fchmod(fno, st.st_mode | stat.S_IWUSR) + except OSError as err: + if err.errno != errno.EPERM: + raise + raise OSError('Failed to change permissions of {} to {} ({}), with error: {}. Most likely the {} directory has a restrictive umask'.format( + temp.name, oct(st.st_mode), format_permissions(st.st_mode), errno.errorcode[err.errno], os.path.dirname(temp.name))) + st = os.stat(fno) if st is not None: try: - os.fchmod(fno, st.st_mode | stat.S_IWUSR) + os.fchmod(fno, st.st_mode) except OSError as err: if err.errno != errno.EPERM: |
||
![]() |
![]() |
![]() |
#12 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Dec 2022
Location: in UTC+1 TZ
Device: PocketBook Touch Lux 4
|
How long does it usually take the moderators (there's 10 of them listed?), to review the posts before they appear here? The first I sent appeared in minutes but I sent a reply over 12 hours ago and it's still not here… Not a great experience for a new member.
![]() |
![]() |
![]() |
![]() |
#13 |
Still reading
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 14,033
Karma: 105092227
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
|
Look at the date!
Also a very active worldwide site. |
![]() |
![]() |
![]() |
#14 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Dec 2022
Location: in UTC+1 TZ
Device: PocketBook Touch Lux 4
|
What about the date? And why these last posts appear immediately? Not all are reviewed by moderators? How come?
|
![]() |
![]() |
![]() |
#15 |
Still reading
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 14,033
Karma: 105092227
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
|
Holiday season
Not all of the Moderators are active all the time. They have real lives. Generally only new members have posts in a moderation queue and it's because of spammers. This is a brilliant and well moderated site. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Javascript files not referenced in ebook-editor | dmonasse | Editor | 2 | 04-17-2014 07:37 AM |
calibre's ebook viewer unable to open/read some .azw3 files | bauerhjb | Calibre | 1 | 05-19-2013 09:51 AM |
Associating ebook files with Calibre ebook viewer | zobop | Library Management | 1 | 06-24-2012 11:07 AM |
Calibre 0.8.12 Overwrites 'Im_Reading' and 'Read' Status on original Kobo | GMFuller | Devices | 4 | 07-31-2011 02:12 AM |