| 1566 | } |
| 1567 | |
| 1568 | void ghb_low_disk_check (signal_user_data_t *ud) |
| 1569 | { |
| 1570 | GtkWindow *hb_window; |
| 1571 | GtkWidget *dialog, *cancel; |
| 1572 | ghb_status_t status; |
| 1573 | const char *dest; |
| 1574 | gint64 free_size; |
| 1575 | gint64 free_limit; |
| 1576 | GhbValue *qDict; |
| 1577 | GhbValue *settings; |
| 1578 | |
| 1579 | if (skip_disk_space_check || !ghb_dict_get_bool(ud->prefs, "DiskFreeCheck")) |
| 1580 | { |
| 1581 | return; |
| 1582 | } |
| 1583 | |
| 1584 | ghb_get_status(&status); |
| 1585 | if (status.queue.unique_id <= 0) |
| 1586 | { |
| 1587 | // No current job |
| 1588 | return; |
| 1589 | } |
| 1590 | ghb_find_queue_job(ud->queue, status.queue.unique_id, &qDict); |
| 1591 | if (qDict == NULL) |
| 1592 | { |
| 1593 | // Failed to find queue setting! |
| 1594 | return; |
| 1595 | } |
| 1596 | settings = ghb_dict_get(qDict, "uiSettings"); |
| 1597 | free_size = dest_free_space(settings); |
| 1598 | if (free_size < 0) |
| 1599 | { |
| 1600 | // Failed to read free space |
| 1601 | return; |
| 1602 | } |
| 1603 | // limit is in GB |
| 1604 | free_limit = ghb_dict_get_int(ud->prefs, "DiskFreeLimitGB") * 1000 * 1000 * 1000; |
| 1605 | if (free_size > free_limit) |
| 1606 | { |
| 1607 | return; |
| 1608 | } |
| 1609 | |
| 1610 | ghb_pause_queue(); |
| 1611 | ghb_send_notification(GHB_NOTIFY_PAUSED_LOW_DISK_SPACE, free_size, ud); |
| 1612 | dest = ghb_dict_get_string(settings, "destination"); |
| 1613 | hb_window = GTK_WINDOW(ghb_builder_widget("hb_window")); |
| 1614 | dialog = gtk_message_dialog_new(hb_window, GTK_DIALOG_MODAL, |
| 1615 | GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE, |
| 1616 | _("Low Disk Space: Encoding Paused")); |
| 1617 | g_autofree char *size_str = ghb_format_pretty_size(free_size); |
| 1618 | gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), |
| 1619 | _("The destination filesystem is almost full: %s free.\n" |
| 1620 | "Destination: %s\n" |
| 1621 | "Encode may be incomplete if you proceed."), |
| 1622 | size_str, dest); |
| 1623 | gtk_dialog_add_buttons( GTK_DIALOG(dialog), |
| 1624 | _("Resume, I've fixed the problem"), 1, |
| 1625 | _("Resume, Don't tell me again"), 2, |
no test coverage detected