mirror of
https://github.com/morgan9e/warehouse
synced 2026-04-14 00:04:08 +09:00
Fix snapshot creation cancelling
This commit is contained in:
@@ -95,6 +95,7 @@ class NewSnapshotDialog(Adw.Dialog):
|
||||
if stopped_workers_amount == len(self.workers):
|
||||
self.loading_status.progress_bar.set_fraction(1)
|
||||
self.loading_status.progress_label.set_label(f"{len(self.workers)} / {len(self.workers)}")
|
||||
self.workers.clear()
|
||||
if self.on_done:
|
||||
self.on_done()
|
||||
|
||||
|
||||
@@ -204,7 +204,6 @@ class SnapshotPage(Adw.BreakpointBin):
|
||||
|
||||
def end_loading(self):
|
||||
def callback(*args):
|
||||
self.new_snapshot_dialog = NewSnapshotDialog(self, self.snapshotting_status, self.refresh)
|
||||
self.generate_active_list()
|
||||
self.generate_leftover_list()
|
||||
if (not self.active_box.get_visible()) and (not self.leftover_box.get_visible()):
|
||||
@@ -224,10 +223,14 @@ class SnapshotPage(Adw.BreakpointBin):
|
||||
self.toast_overlay.add_toast(ErrorToast(_("Could not open folder"), str(e)).toast)
|
||||
|
||||
def on_cancel(self):
|
||||
for worker in self.workers:
|
||||
worker.do_cancel("manual_cancel")
|
||||
|
||||
for worker in self.new_snapshot_dialog.workers:
|
||||
worker.do_cancel("manual_cancel")
|
||||
|
||||
def on_new(self, *args):
|
||||
self.new_snapshot_dialog = NewSnapshotDialog(self, self.snapshotting_status, self.refresh)
|
||||
self.new_snapshot_dialog.present(HostInfo.main_window)
|
||||
|
||||
def refresh(self):
|
||||
@@ -347,7 +350,8 @@ class SnapshotPage(Adw.BreakpointBin):
|
||||
self.toast_overlay.add_toast(Adw.Toast(title=_("No apps in your selection can be snapshotted")))
|
||||
return
|
||||
|
||||
NewSnapshotDialog(self, self.snapshotting_status, self.refresh, packages).present(HostInfo.main_window)
|
||||
self.new_snapshot_dialog = NewSnapshotDialog(self, self.snapshotting_status, self.refresh, packages)
|
||||
self.new_snapshot_dialog.present(HostInfo.main_window)
|
||||
|
||||
def get_snapshots_from_entry(self, app_ids):
|
||||
id_to_tar = {}
|
||||
@@ -379,6 +383,7 @@ class SnapshotPage(Adw.BreakpointBin):
|
||||
self.snapshotting_status.progress_bar.set_fraction(1)
|
||||
self.snapshotting_status.progress_label.set_label(f"{len(self.workers)} / {len(self.workers)}")
|
||||
HostInfo.main_window.refresh_handler()
|
||||
self.workers.clear()
|
||||
return False
|
||||
|
||||
self.snapshotting_status.progress_label.set_label(f"{stopped_workers_amount + 1} / {len(self.workers)}")
|
||||
|
||||
@@ -15,6 +15,7 @@ class TarWorker:
|
||||
self.total = 0
|
||||
self.process = None
|
||||
self.toast_overlay = toast_overlay
|
||||
self.has_cancelled = False
|
||||
|
||||
def compress_thread(self, *args):
|
||||
try:
|
||||
@@ -76,6 +77,10 @@ class TarWorker:
|
||||
self.do_cancel(str(e), [self.new_path])
|
||||
|
||||
def do_cancel(self, error_str, files_to_trash=None):
|
||||
if self.has_cancelled:
|
||||
return
|
||||
|
||||
self.has_cancelled = True
|
||||
self.process.terminate()
|
||||
self.process.wait()
|
||||
if not files_to_trash is None:
|
||||
|
||||
Reference in New Issue
Block a user