Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 11-21-2021, 09:56 AM   #1
lomkiri
Groupie
lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.
 
lomkiri's Avatar
 
Posts: 167
Karma: 1497966
Join Date: Jul 2021
Device: N/A
[Plugin] How to delete a checkpoint?

Hi,

In a plugin, is there any way to delete a checkpoint by it's name, without action on the container?
I would like to do something like this:
Code:
for i, some_action in enumerate(actions):
	point_name = 'partial checkpoint n. {}'.format(i)
	self.boss.add_savepoint(point_name)
	some_action()	# user get a win-diff and may rewind_savepoint() or not

        # if still existing, just delete our CP with no rewind action,
        # as it's not needeed anymore:
	self.boss.delete_savepoint(point_name)
I ask this because the for loop may create a lot of actions (maybe more than 100, in some circumstances), and I don't want to have the risk to reach MAX_SAVEPOINTS (100, from what I've seen ?).

By the way, is the creation of checkpoints a memory consuming process? Does it have much impact on the performances ?

Thank you.

Last edited by lomkiri; 11-21-2021 at 10:00 AM.
lomkiri is offline   Reply With Quote
Old 11-21-2021, 09:59 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
No, checkpoints dont have names. They just have some descriptive text which is not guaranteed to be unique. If you want to perform lots of operations its best to just create a checkpoint before the whole set.

And no checkpoints are stored on disk not in ram and creating them is very cheap as they use copy-on-write and hard links.
kovidgoyal is offline   Reply With Quote
Advert
Old 11-21-2021, 10:08 AM   #3
lomkiri
Groupie
lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.
 
lomkiri's Avatar
 
Posts: 167
Karma: 1497966
Join Date: Jul 2021
Device: N/A
Thank you , Kovid !

It's annoying because I would need granularity: the user will have the possibility to interpose personal changes in the ebook between two "some_action" and I would like not to revert those ones.

It is not possible either to delete the last one, with no rewind action ?

The limit is effectively 100 ? What happens if we reach this limit ? CP is not created, or first ones are deleted, or an exception is raised ?

Last edited by lomkiri; 11-21-2021 at 10:11 AM.
lomkiri is offline   Reply With Quote
Old 11-21-2021, 10:21 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You can rewind the last checkpoint with rewind_savepoint(). And if you exceed the limit old checkpoints are removed.
kovidgoyal is offline   Reply With Quote
Old 11-21-2021, 10:57 AM   #5
lomkiri
Groupie
lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.
 
lomkiri's Avatar
 
Posts: 167
Karma: 1497966
Join Date: Jul 2021
Device: N/A
Ok, thanks. I'll do as you said and generate more generalistic CPs. The confirm box will warn the user that rewinding will also undo his own changes.
lomkiri is offline   Reply With Quote
Advert
Reply

Tags
checkpoint, plugin


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[REQ] A plugin that delete class in the chapter Auramazda Plugins 14 09-21-2016 10:57 AM
Using "Delete Duplicates" Plugin Beemerang Plugins 3 10-30-2014 02:04 AM
Q: Should [Delete File] also delete <link>? phossler Editor 5 01-02-2014 04:38 AM
Is there a plugin that will search a library to delete the ORIGINAL_EPUB files LadyKate Library Management 4 11-09-2013 09:02 PM
Delete files in PC not equal to delete in Sony reader 505 sheilalayoli Sony Reader 5 07-12-2009 03:13 PM


All times are GMT -4. The time now is 11:49 AM.


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