diff -pruN mc-4.7.5.1-orig/src/filemanager/file.c mc-4.7.5.1/src/filemanager/file.c
old
|
new
|
erase_file (FileOpTotalContext * tctx, F |
674 | 674 | |
675 | 675 | while (mc_unlink (s) != 0) |
676 | 676 | { |
| 677 | if ( ctx->skip_all ) |
| 678 | break; |
677 | 679 | return_status = file_error (_("Cannot delete file \"%s\"\n%s"), s); |
678 | | if (return_status != FILE_RETRY) |
| 680 | if (return_status == FILE_ABORT) |
679 | 681 | return return_status; |
| 682 | if (return_status == FILE_RETRY) |
| 683 | continue; |
| 684 | if (return_status == FILE_SKIPALL) |
| 685 | ctx->skip_all = 1; |
| 686 | break; |
680 | 687 | } |
681 | 688 | |
682 | 689 | if (tctx->progress_count == 0) |
… |
… |
erase_file (FileOpTotalContext * tctx, F |
686 | 693 | |
687 | 694 | /* --------------------------------------------------------------------------------------------- */ |
688 | 695 | |
| 696 | /* recursive remove of files |
| 697 | abort->cancel stack |
| 698 | skip ->warn every level, gets default |
| 699 | skipall->remove as much as possible |
| 700 | */ |
689 | 701 | static FileProgressStatus |
690 | 702 | recursive_erase (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s) |
691 | 703 | { |
… |
… |
recursive_erase (FileOpTotalContext * tc |
703 | 715 | if (!reading) |
704 | 716 | return FILE_RETRY; |
705 | 717 | |
706 | | while ((next = mc_readdir (reading)) && return_status == FILE_CONT) |
| 718 | while ((next = mc_readdir (reading)) && !(return_status == FILE_ABORT)) |
707 | 719 | { |
708 | 720 | if (!strcmp (next->d_name, ".")) |
709 | 721 | continue; |
… |
… |
recursive_erase (FileOpTotalContext * tc |
718 | 730 | } |
719 | 731 | if (S_ISDIR (buf.st_mode)) |
720 | 732 | return_status = |
721 | | (recursive_erase (tctx, ctx, path) != FILE_CONT) ? FILE_RETRY : FILE_CONT; |
| 733 | recursive_erase (tctx, ctx, path); |
722 | 734 | else |
723 | 735 | return_status = erase_file (tctx, ctx, path, 0); |
724 | 736 | g_free (path); |
725 | 737 | } |
726 | 738 | mc_closedir (reading); |
727 | | if (return_status != FILE_CONT) |
| 739 | if (return_status == FILE_ABORT) |
728 | 740 | return return_status; |
729 | 741 | file_progress_show_deleting (ctx, s); |
730 | 742 | if (check_progress_buttons (ctx) == FILE_ABORT) |
… |
… |
recursive_erase (FileOpTotalContext * tc |
733 | 745 | |
734 | 746 | while (my_rmdir (s)) |
735 | 747 | { |
| 748 | if ( ctx->skip_all ) |
| 749 | break; |
736 | 750 | return_status = file_error (_("Cannot remove directory \"%s\"\n%s"), s); |
737 | | if (return_status != FILE_RETRY) |
| 751 | if (return_status == FILE_RETRY) |
| 752 | continue; |
| 753 | if (return_status == FILE_ABORT) |
738 | 754 | return return_status; |
| 755 | if (return_status == FILE_SKIPALL) |
| 756 | ctx->skip_all = 1; |
| 757 | break; |
739 | 758 | } |
740 | 759 | |
741 | 760 | return FILE_CONT; |
… |
… |
real_do_file_error (enum OperationMode m |
1069 | 1088 | const char *msg; |
1070 | 1089 | |
1071 | 1090 | msg = mode == Foreground ? MSG_ERROR : _("Background process error"); |
1072 | | result = query_dialog (msg, error, D_ERROR, 3, _("&Skip"), _("&Retry"), _("&Abort")); |
| 1091 | result = query_dialog (msg, error, D_ERROR, 4, _("&Skip"), _("Ski&p All"), _("&Retry"), _("&Abort")); |
1073 | 1092 | |
1074 | 1093 | switch (result) |
1075 | 1094 | { |
… |
… |
real_do_file_error (enum OperationMode m |
1079 | 1098 | |
1080 | 1099 | case 1: |
1081 | 1100 | do_refresh (); |
1082 | | return FILE_RETRY; |
| 1101 | return FILE_SKIPALL; |
1083 | 1102 | |
1084 | 1103 | case 2: |
| 1104 | do_refresh (); |
| 1105 | return FILE_RETRY; |
| 1106 | |
| 1107 | case 3: |
1085 | 1108 | default: |
1086 | 1109 | return FILE_ABORT; |
1087 | 1110 | } |
… |
… |
copy_file_file (FileOpTotalContext * tct |
1321 | 1344 | { |
1322 | 1345 | while (mc_mknod (dst_path, sb.st_mode & ctx->umask_kill, sb.st_rdev) < 0) |
1323 | 1346 | { |
| 1347 | if ( ctx->skip_all ) |
| 1348 | break; |
1324 | 1349 | return_status = file_error (_("Cannot create special file \"%s\"\n%s"), dst_path); |
1325 | 1350 | if (return_status == FILE_RETRY) |
1326 | 1351 | continue; |
| 1352 | if (return_status == FILE_SKIPALL) |
| 1353 | ctx->skip_all = 1; |
1327 | 1354 | return return_status; |
1328 | 1355 | } |
1329 | 1356 | /* Success */ |
1330 | 1357 | |
1331 | 1358 | while (ctx->preserve_uidgid && mc_chown (dst_path, sb.st_uid, sb.st_gid)) |
1332 | 1359 | { |
| 1360 | if ( ctx->skip_all ) |
| 1361 | break; |
1333 | 1362 | temp_status = file_error (_("Cannot chown target file \"%s\"\n%s"), dst_path); |
| 1363 | if (temp_status == FILE_SKIPALL) |
| 1364 | ctx->skip_all = 1; |
| 1365 | if (temp_status == FILE_SKIP) |
| 1366 | break; |
1334 | 1367 | if (temp_status == FILE_RETRY) |
1335 | 1368 | continue; |
1336 | 1369 | return temp_status; |
1337 | 1370 | } |
1338 | 1371 | while (ctx->preserve && mc_chmod (dst_path, sb.st_mode & ctx->umask_kill)) |
1339 | 1372 | { |
| 1373 | if ( ctx->skip_all ) |
| 1374 | break; |
1340 | 1375 | temp_status = file_error (_("Cannot chmod target file \"%s\"\n%s"), dst_path); |
| 1376 | if (temp_status == FILE_SKIPALL) |
| 1377 | ctx->skip_all = 1; |
| 1378 | if (temp_status == FILE_SKIP) |
| 1379 | break; |
1341 | 1380 | if (temp_status == FILE_RETRY) |
1342 | 1381 | continue; |
1343 | 1382 | return temp_status; |
… |
… |
copy_file_file (FileOpTotalContext * tct |
1350 | 1389 | |
1351 | 1390 | while ((src_desc = mc_open (src_path, O_RDONLY | O_LINEAR)) < 0) |
1352 | 1391 | { |
| 1392 | if ( ctx->skip_all ) |
| 1393 | break; |
1353 | 1394 | return_status = file_error (_("Cannot open source file \"%s\"\n%s"), src_path); |
1354 | 1395 | if (return_status == FILE_RETRY) |
1355 | 1396 | continue; |
| 1397 | if (return_status == FILE_SKIPALL) |
| 1398 | ctx->skip_all = 1; |
| 1399 | if (return_status == FILE_SKIP) |
| 1400 | break; |
1356 | 1401 | ctx->do_append = 0; |
1357 | 1402 | return return_status; |
1358 | 1403 | } |
… |
… |
copy_file_file (FileOpTotalContext * tct |
1369 | 1414 | |
1370 | 1415 | while (mc_fstat (src_desc, &sb)) |
1371 | 1416 | { |
| 1417 | if ( ctx->skip_all ) |
| 1418 | goto ret; |
1372 | 1419 | return_status = file_error (_("Cannot fstat source file \"%s\"\n%s"), src_path); |
1373 | 1420 | if (return_status == FILE_RETRY) |
1374 | 1421 | continue; |
| 1422 | if (return_status == FILE_SKIPALL) |
| 1423 | ctx->skip_all = 1; |
1375 | 1424 | ctx->do_append = FALSE; |
1376 | 1425 | goto ret; |
1377 | 1426 | } |
… |
… |
copy_file_file (FileOpTotalContext * tct |
1399 | 1448 | { |
1400 | 1449 | if (errno == EEXIST) |
1401 | 1450 | goto ret; |
| 1451 | if ( ctx->skip_all ) |
| 1452 | goto ret; |
1402 | 1453 | |
1403 | 1454 | return_status = file_error (_("Cannot create target file \"%s\"\n%s"), dst_path); |
1404 | 1455 | if (return_status == FILE_RETRY) |
1405 | 1456 | continue; |
| 1457 | if (return_status == FILE_SKIPALL) |
| 1458 | ctx->skip_all = 1; |
1406 | 1459 | ctx->do_append = FALSE; |
1407 | 1460 | goto ret; |
1408 | 1461 | } |
… |
… |
copy_file_file (FileOpTotalContext * tct |
1414 | 1467 | /* Find out the optimal buffer size. */ |
1415 | 1468 | while (mc_fstat (dest_desc, &sb)) |
1416 | 1469 | { |
| 1470 | if ( ctx->skip_all ) |
| 1471 | goto ret; |
1417 | 1472 | return_status = file_error (_("Cannot fstat target file \"%s\"\n%s"), dst_path); |
1418 | 1473 | if (return_status == FILE_RETRY) |
1419 | 1474 | continue; |
| 1475 | if (return_status == FILE_SKIPALL) |
| 1476 | ctx->skip_all = 1; |
1420 | 1477 | goto ret; |
1421 | 1478 | } |
1422 | 1479 | |
… |
… |
copy_file_file (FileOpTotalContext * tct |
1450 | 1507 | else |
1451 | 1508 | while ((n_read = mc_read (src_desc, buf, sizeof (buf))) < 0) |
1452 | 1509 | { |
| 1510 | if ( ctx->skip_all ) |
| 1511 | goto ret; |
1453 | 1512 | return_status = file_error (_("Cannot read source file\"%s\"\n%s"), src_path); |
1454 | 1513 | if (return_status == FILE_RETRY) |
1455 | 1514 | continue; |
| 1515 | if (return_status == FILE_SKIPALL) |
| 1516 | ctx->skip_all = 1; |
1456 | 1517 | goto ret; |
1457 | 1518 | } |
1458 | 1519 | if (n_read == 0) |
… |
… |
copy_file_file (FileOpTotalContext * tct |
1476 | 1537 | /* dst_write */ |
1477 | 1538 | while ((n_written = mc_write (dest_desc, t, n_read)) < n_read) |
1478 | 1539 | { |
| 1540 | if ( ctx->skip_all ) |
| 1541 | break; |
1479 | 1542 | if (n_written > 0) |
1480 | 1543 | { |
1481 | 1544 | n_read -= n_written; |
… |
… |
copy_file_file (FileOpTotalContext * tct |
1483 | 1546 | continue; |
1484 | 1547 | } |
1485 | 1548 | return_status = file_error (_("Cannot write target file \"%s\"\n%s"), dst_path); |
| 1549 | if (return_status == FILE_SKIPALL) |
| 1550 | ctx->skip_all = 1; |
| 1551 | if (return_status == FILE_SKIP) |
| 1552 | break; |
1486 | 1553 | if (return_status != FILE_RETRY) |
1487 | 1554 | goto ret; |
1488 | 1555 | } |
… |
… |
copy_file_file (FileOpTotalContext * tct |
1538 | 1605 | ret: |
1539 | 1606 | while (src_desc != -1 && mc_close (src_desc) < 0) |
1540 | 1607 | { |
| 1608 | if ( ctx->skip_all ) |
| 1609 | break; |
1541 | 1610 | temp_status = file_error (_("Cannot close source file \"%s\"\n%s"), src_path); |
1542 | 1611 | if (temp_status == FILE_RETRY) |
1543 | 1612 | continue; |
1544 | 1613 | if (temp_status == FILE_ABORT) |
1545 | 1614 | return_status = temp_status; |
| 1615 | if (temp_status == FILE_SKIPALL) |
| 1616 | ctx->skip_all = 1; |
1546 | 1617 | break; |
1547 | 1618 | } |
1548 | 1619 | |
1549 | 1620 | while (dest_desc != -1 && mc_close (dest_desc) < 0) |
1550 | 1621 | { |
| 1622 | if ( ctx->skip_all ) |
| 1623 | break; |
1551 | 1624 | temp_status = file_error (_("Cannot close target file \"%s\"\n%s"), dst_path); |
1552 | 1625 | if (temp_status == FILE_RETRY) |
1553 | 1626 | continue; |
| 1627 | if (temp_status == FILE_SKIPALL) |
| 1628 | ctx->skip_all = 1; |
1554 | 1629 | return_status = temp_status; |
1555 | 1630 | break; |
1556 | 1631 | } |
… |
… |
copy_file_file (FileOpTotalContext * tct |
1572 | 1647 | { |
1573 | 1648 | while (mc_chown (dst_path, src_uid, src_gid)) |
1574 | 1649 | { |
| 1650 | if ( ctx->skip_all ) |
| 1651 | break; |
1575 | 1652 | temp_status = file_error (_("Cannot chown target file \"%s\"\n%s"), dst_path); |
1576 | 1653 | if (temp_status == FILE_RETRY) |
1577 | 1654 | continue; |
1578 | | return_status = temp_status; |
| 1655 | if (temp_status == FILE_SKIPALL) { |
| 1656 | ctx->skip_all = 1; |
| 1657 | return_status = FILE_CONT; |
| 1658 | } |
| 1659 | if (temp_status == FILE_SKIP) |
| 1660 | return_status = FILE_CONT; |
1579 | 1661 | break; |
1580 | 1662 | } |
1581 | 1663 | } |
… |
… |
copy_file_file (FileOpTotalContext * tct |
1586 | 1668 | { |
1587 | 1669 | while (mc_chmod (dst_path, (src_mode & ctx->umask_kill))) |
1588 | 1670 | { |
1589 | | temp_status = file_error (_("Cannot chmod target file \"%s\"\n%s"), dst_path); |
1590 | | if (temp_status != FILE_RETRY) |
1591 | | { |
1592 | | return_status = temp_status; |
| 1671 | if ( ctx->skip_all ) |
1593 | 1672 | break; |
| 1673 | temp_status = file_error (_("Cannot chmod target file \"%s\"\n%s"), dst_path); |
| 1674 | if (temp_status == FILE_RETRY) |
| 1675 | continue; |
| 1676 | if (temp_status == FILE_SKIPALL){ |
| 1677 | ctx->skip_all = 1; |
| 1678 | return_status = FILE_CONT; |
1594 | 1679 | } |
| 1680 | if (temp_status == FILE_SKIP) |
| 1681 | return_status = FILE_CONT; |
| 1682 | break; |
1595 | 1683 | } |
1596 | 1684 | } |
1597 | 1685 | else |
diff -pruN mc-4.7.5.1-orig/src/filemanager/fileopctx.c mc-4.7.5.1/src/filemanager/fileopctx.c
old
|
new
|
file_op_context_new (FileOperation op) |
78 | 78 | ctx->preserve_uidgid = (geteuid () == 0); |
79 | 79 | ctx->umask_kill = 0777777; |
80 | 80 | ctx->erase_at_end = TRUE; |
| 81 | ctx->skip_all = 0; |
81 | 82 | |
82 | 83 | return ctx; |
83 | 84 | } |
diff -pruN mc-4.7.5.1-orig/src/filemanager/fileopctx.h mc-4.7.5.1/src/filemanager/fileopctx.h
old
|
new
|
typedef enum |
56 | 56 | FILE_CONT = 0, |
57 | 57 | FILE_RETRY = 1, |
58 | 58 | FILE_SKIP = 2, |
59 | | FILE_ABORT = 3 |
| 59 | FILE_ABORT = 3, |
| 60 | FILE_SKIPALL = 4 |
60 | 61 | } FileProgressStatus; |
61 | 62 | |
62 | 63 | /* First argument passed to real functions */ |
… |
… |
typedef struct FileOpContext |
155 | 156 | /* PID of the child for background operations */ |
156 | 157 | pid_t pid; |
157 | 158 | |
| 159 | /* toggle if all errors should be ignored */ |
| 160 | int skip_all; |
| 161 | |
158 | 162 | /* User interface data goes here */ |
159 | 163 | void *ui; |
160 | 164 | } FileOpContext; |