diff --git a/prime_backup/mcdr/command/commands.py b/prime_backup/mcdr/command/commands.py index 4297293..bc8aaa1 100644 --- a/prime_backup/mcdr/command/commands.py +++ b/prime_backup/mcdr/command/commands.py @@ -102,8 +102,8 @@ def cmd_db_migrate_hash_method(self, source: CommandSource, context: CommandCont self.task_manager.add_task(MigrateHashMethodTask(source, new_hash_method)) def cmd_make(self, source: CommandSource, context: CommandContext): - def callback(_, err): - if err is None: + def callback(backup_id: Optional[int], err: Optional[Exception]): + if err is None and backup_id is not None: self.crontab_manager.send_event(CrontabJobEvent.manual_backup_created) comment = context.get('comment', '') diff --git a/prime_backup/mcdr/task/backup/create_backup_task.py b/prime_backup/mcdr/task/backup/create_backup_task.py index 820b3ee..52854b5 100644 --- a/prime_backup/mcdr/task/backup/create_backup_task.py +++ b/prime_backup/mcdr/task/backup/create_backup_task.py @@ -11,7 +11,7 @@ from prime_backup.utils.timer import Timer -class CreateBackupTask(HeavyTask[None]): +class CreateBackupTask(HeavyTask[Optional[int]]): def __init__(self, source: CommandSource, comment: str, operator: Optional[Operator] = None): super().__init__(source) self.comment = comment @@ -28,7 +28,7 @@ def id(self) -> str: def is_abort_able(self) -> bool: return self.__waiting_world_save - def run(self): + def run(self) -> Optional[int]: self.broadcast(self.tr('start')) cmds = self.config.server.commands @@ -47,14 +47,14 @@ def run(self): self.__waiting_world_save = False if self.aborted_event.is_set(): self.broadcast(self.get_aborted_text()) - return + return None if not ok: self.broadcast(self.tr('abort.save_wait_time_out').set_color(RColor.red)) - return + return None cost_save_wait = timer.get_and_restart() if self.plugin_unloaded_event.is_set(): self.broadcast(self.tr('abort.unloaded').set_color(RColor.red)) - return + return None action = CreateBackupAction(self.operator, self.comment) backup = action.run() @@ -75,6 +75,7 @@ def run(self): TextComponents.backup_size(backup), TextComponents.blob_list_summary_store_size(bls), )) + return backup.id finally: if applied_auto_save_off and len(cmds.auto_save_on) > 0: self.server.execute(cmds.auto_save_on)