mirror of
https://github.com/morgan9e/warehouse
synced 2026-04-14 00:04:08 +09:00
Use error toast for snapshotting
This commit is contained in:
@@ -120,6 +120,7 @@ class NewSnapshotDialog(Adw.Dialog):
|
||||
new_path=f"{HostInfo.snapshots_path}{package.info['id']}",
|
||||
file_name=f"{int(time.time())}_{package.info["version"]}",
|
||||
name=self.name_entry.get_text(),
|
||||
toast_overlay=self.snapshot_page.toast_overlay,
|
||||
)
|
||||
self.workers.append(worker)
|
||||
worker.compress()
|
||||
|
||||
@@ -158,6 +158,7 @@ class SnapshotBox(Gtk.Box):
|
||||
existing_path=f"{snapshots_path}{folder}",
|
||||
new_path=f"{HostInfo.home}/.var/app/{self.app_id}/",
|
||||
file_name=self.app_id,
|
||||
toast_overlay=self.toast_overlay,
|
||||
)
|
||||
|
||||
split_folder = folder.split('_')
|
||||
|
||||
@@ -4,7 +4,7 @@ from .error_toast import ErrorToast
|
||||
import os, tarfile, subprocess, json
|
||||
|
||||
class TarWorker:
|
||||
def __init__(self, existing_path, new_path, file_name, name=""):
|
||||
def __init__(self, existing_path, new_path, file_name, name="", toast_overlay=None):
|
||||
self.existing_path = existing_path
|
||||
self.new_path = new_path
|
||||
self.file_name = file_name
|
||||
@@ -14,6 +14,7 @@ class TarWorker:
|
||||
self.fraction = 0.0
|
||||
self.total = 0
|
||||
self.process = None
|
||||
self.toast_overlay = toast_overlay
|
||||
|
||||
def compress_thread(self, *args):
|
||||
try:
|
||||
@@ -80,13 +81,14 @@ class TarWorker:
|
||||
if not files_to_trash is None:
|
||||
try:
|
||||
subprocess.run(['gio', 'trash'] + files_to_trash, capture_output=True, check=True)
|
||||
|
||||
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
self.stop = True
|
||||
print("Error in cancelling:", error_str)
|
||||
|
||||
if self.toast_overlay:
|
||||
self.toast_overlay.add_toast(ErrorToast(_("Error in snapshot handling"), error_str).toast)
|
||||
|
||||
def check_size(self, check_path):
|
||||
try:
|
||||
output = subprocess.run(['du', '-s', check_path], check=True, text=True, capture_output=True).stdout.split('\t')[0]
|
||||
|
||||
Reference in New Issue
Block a user