summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzhuyaliang <[email protected]>2023-08-04 11:11:16 +0800
committerLuke from DC <[email protected]>2023-08-11 05:13:16 +0000
commit248ef1aa5a6bbaa65387508b81f3fe2ebbc5ec7d (patch)
treecff16a6769c26601e2c95fbcb0c2b491f65415fb /src
parent45f52c13baa93857d912effb4f1f9a58c41a0da3 (diff)
downloadengrampa-248ef1aa5a6bbaa65387508b81f3fe2ebbc5ec7d.tar.bz2
engrampa-248ef1aa5a6bbaa65387508b81f3fe2ebbc5ec7d.tar.xz
Check if the remaining disk space is sufficient when add extract
Diffstat (limited to 'src')
-rw-r--r--src/fr-window.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/fr-window.c b/src/fr-window.c
index cbb0ea6..20ca551 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -6419,6 +6419,34 @@ archive_is_encrypted (FrWindow *window,
return encrypted;
}
+static gboolean
+archive_extract_check_disk_space_full (GPtrArray *files,
+ const char *extract_to_dir)
+{
+ guint64 freespace;
+ guint64 archive_size = 0;
+ guint i;
+
+ freespace = get_dest_free_space (g_filename_from_uri (extract_to_dir, NULL, NULL));
+
+ for (i = 0; i <files->len; i++)
+ {
+ FileData *fdata = g_ptr_array_index (files, i);
+ archive_size += fdata->size;
+ }
+ /* When the decompressed target file is less than 100MB,
+ 2 * (target file size) needs to disk space
+ and when it is greater than 100MB,
+ 100MB + (target file size) needs to disk space */
+
+ if (archive_size <= 1024 * 1024 * 100)
+ archive_size = archive_size * 2;
+ else
+ archive_size += 1024 * 1024 * 100;
+
+ return freespace < archive_size * 2;
+}
+
void
fr_window_archive_extract_here (FrWindow *window,
gboolean skip_older,
@@ -6672,6 +6700,20 @@ fr_window_archive_extract (FrWindow *window,
edata,
(GFreeFunc) extract_data_free);
+ if (archive_extract_check_disk_space_full (window->archive->command->files, extract_to_dir))
+ {
+ GtkWidget *d;
+
+ d = _gtk_error_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_MODAL,
+ NULL,
+ _("Insufficient remaining disk space"),
+ NULL);
+ gtk_dialog_run (GTK_DIALOG (d));
+ gtk_widget_destroy(d);
+ return;
+ }
+
if (archive_is_encrypted (window, edata->file_list) && (window->priv->password == NULL)) {
dlg_ask_password (window);
return;