Last-Update: 2012-06-24
Applied-Upstream: 4.8.4
Bug-MC: https://www.midnight-commander.org/ticket/2829
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=677038
Description: backported fix for 'Loss of data on copy to full partition'
a
|
b
|
|
1404 | 1404 | int open_flags; |
1405 | 1405 | gboolean is_first_time = TRUE; |
1406 | 1406 | vfs_path_t *src_vpath = NULL, *dst_vpath = NULL; |
| 1407 | gboolean write_errno_nospace = FALSE; |
1407 | 1408 | |
1408 | 1409 | /* FIXME: We should not be using global variables! */ |
1409 | 1410 | ctx->do_reget = 0; |
… |
… |
|
1726 | 1727 | gettimeofday (&tv_last_input, NULL); |
1727 | 1728 | |
1728 | 1729 | /* dst_write */ |
1729 | | while ((n_written = mc_write (dest_desc, t, n_read)) < n_read && !ctx->skip_all) |
| 1730 | while ((n_written = mc_write (dest_desc, t, n_read)) < n_read) |
1730 | 1731 | { |
1731 | 1732 | if (n_written > 0) |
1732 | 1733 | { |
… |
… |
|
1734 | 1735 | t += n_written; |
1735 | 1736 | continue; |
1736 | 1737 | } |
1737 | | return_status = file_error (_("Cannot write target file \"%s\"\n%s"), dst_path); |
| 1738 | |
| 1739 | write_errno_nospace = (n_written < 0 && errno == ENOSPC); |
| 1740 | |
| 1741 | if (ctx->skip_all) |
| 1742 | return_status = FILE_SKIPALL; |
| 1743 | else |
| 1744 | return_status = |
| 1745 | file_error (_("Cannot write target file \"%s\"\n%s"), dst_path); |
| 1746 | |
1738 | 1747 | if (return_status == FILE_SKIP) |
| 1748 | { |
| 1749 | if (write_errno_nospace) |
| 1750 | goto ret; |
1739 | 1751 | break; |
| 1752 | } |
1740 | 1753 | if (return_status == FILE_SKIPALL) |
| 1754 | { |
1741 | 1755 | ctx->skip_all = TRUE; |
| 1756 | if (write_errno_nospace) |
| 1757 | goto ret; |
| 1758 | } |
1742 | 1759 | if (return_status != FILE_RETRY) |
1743 | 1760 | goto ret; |
1744 | 1761 | } |
… |
… |
|
1819 | 1836 | if (dst_status == DEST_SHORT) |
1820 | 1837 | { |
1821 | 1838 | /* Remove short file */ |
1822 | | int result; |
| 1839 | int result = 0; |
1823 | 1840 | |
1824 | | result = query_dialog (Q_ ("DialogTitle|Copy"), |
1825 | | _("Incomplete file was retrieved. Keep it?"), |
1826 | | D_ERROR, 2, _("&Delete"), _("&Keep")); |
| 1841 | /* In case of copy/move to full partition, keep source file |
| 1842 | * and remove incomplete destination one */ |
| 1843 | if (!write_errno_nospace) |
| 1844 | result = query_dialog (Q_ ("DialogTitle|Copy"), |
| 1845 | _("Incomplete file was retrieved. Keep it?"), |
| 1846 | D_ERROR, 2, _("&Delete"), _("&Keep")); |
1827 | 1847 | if (result == 0) |
1828 | 1848 | mc_unlink (dst_vpath); |
1829 | 1849 | } |