diff -pruN mc-4.7.0.8-orig/src/file.c mc-4.7.0.8/src/file.c
old
|
new
|
copy_file_file (FileOpContext *ctx, cons |
511 | 511 | S_ISSOCK (sb.st_mode)) { |
512 | 512 | while (mc_mknod (dst_path, sb.st_mode & ctx->umask_kill, |
513 | 513 | sb.st_rdev) < 0) { |
| 514 | if ( ctx->skip_all ) |
| 515 | break; |
514 | 516 | return_status = file_error ( |
515 | 517 | _(" Cannot create special file \"%s\" \n %s "), dst_path); |
516 | 518 | if (return_status == FILE_RETRY) |
517 | 519 | continue; |
| 520 | if (return_status == FILE_SKIPALL) |
| 521 | ctx->skip_all = 1; |
| 522 | if (return_status == FILE_SKIP); |
518 | 523 | return return_status; |
519 | 524 | } |
520 | 525 | /* Success */ |
521 | 526 | |
522 | 527 | while (ctx->preserve_uidgid |
523 | 528 | && mc_chown (dst_path, sb.st_uid, sb.st_gid)) { |
| 529 | if ( ctx->skip_all ) |
| 530 | break; |
524 | 531 | temp_status = file_error ( |
525 | 532 | _(" Cannot chown target file \"%s\" \n %s "), dst_path); |
| 533 | if (temp_status == FILE_SKIPALL) |
| 534 | ctx->skip_all = 1; |
| 535 | if (temp_status == FILE_SKIP) |
| 536 | break; |
526 | 537 | if (temp_status == FILE_RETRY) |
527 | 538 | continue; |
528 | 539 | return temp_status; |
529 | 540 | } |
530 | 541 | while (ctx->preserve && |
531 | 542 | mc_chmod (dst_path, sb.st_mode & ctx->umask_kill)) { |
| 543 | if ( ctx->skip_all ) |
| 544 | break; |
532 | 545 | temp_status = file_error ( |
533 | 546 | _(" Cannot chmod target file \"%s\" \n %s "), dst_path); |
| 547 | if (temp_status == FILE_SKIPALL) |
| 548 | ctx->skip_all = 1; |
| 549 | if (temp_status == FILE_SKIP) |
| 550 | break; |
534 | 551 | if (temp_status == FILE_RETRY) |
535 | 552 | continue; |
536 | 553 | return temp_status; |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
542 | 559 | gettimeofday (&tv_transfer_start, (struct timezone *) NULL); |
543 | 560 | |
544 | 561 | while ((src_desc = mc_open (src_path, O_RDONLY | O_LINEAR)) < 0) { |
| 562 | if ( ctx->skip_all ) |
| 563 | break; |
545 | 564 | return_status = file_error ( |
546 | 565 | _(" Cannot open source file \"%s\" \n %s "), src_path); |
547 | 566 | if (return_status == FILE_RETRY) |
548 | 567 | continue; |
| 568 | if (return_status == FILE_SKIPALL) |
| 569 | ctx->skip_all = 1; |
| 570 | if (return_status == FILE_SKIP) |
| 571 | break; |
549 | 572 | ctx->do_append = 0; |
550 | 573 | return return_status; |
551 | 574 | } |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
559 | 582 | } |
560 | 583 | |
561 | 584 | while (mc_fstat (src_desc, &sb)) { |
| 585 | if ( ctx->skip_all ) |
| 586 | goto ret; |
562 | 587 | return_status = file_error ( |
563 | 588 | _(" Cannot fstat source file \"%s\" \n %s "), src_path); |
564 | 589 | if (return_status == FILE_RETRY) |
565 | 590 | continue; |
| 591 | if (return_status == FILE_SKIPALL) |
| 592 | ctx->skip_all = 1; |
| 593 | if (return_status == FILE_SKIP); |
566 | 594 | ctx->do_append = 0; |
567 | 595 | goto ret; |
568 | 596 | } |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
586 | 614 | if (errno == EEXIST) { |
587 | 615 | goto ret; |
588 | 616 | } |
| 617 | if ( ctx->skip_all ) |
| 618 | goto ret; |
589 | 619 | return_status = file_error ( |
590 | 620 | _(" Cannot create target file \"%s\" \n %s "), dst_path); |
591 | 621 | if (return_status == FILE_RETRY) |
592 | 622 | continue; |
| 623 | if (return_status == FILE_SKIPALL) |
| 624 | ctx->skip_all = 1; |
| 625 | if (return_status == FILE_SKIP); |
593 | 626 | ctx->do_append = 0; |
594 | 627 | goto ret; |
595 | 628 | } |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
600 | 633 | |
601 | 634 | /* Find out the optimal buffer size. */ |
602 | 635 | while (mc_fstat (dest_desc, &sb)) { |
| 636 | if ( ctx->skip_all ) |
| 637 | goto ret; |
603 | 638 | return_status = file_error ( |
604 | 639 | _(" Cannot fstat target file \"%s\" \n %s "), dst_path); |
605 | 640 | if (return_status == FILE_RETRY) |
606 | 641 | continue; |
| 642 | if (return_status == FILE_SKIPALL) |
| 643 | ctx->skip_all = 1; |
| 644 | if (return_status == FILE_SKIP); |
607 | 645 | goto ret; |
608 | 646 | } |
609 | 647 | buf = g_malloc (buf_size); |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
632 | 670 | n_read = -1; |
633 | 671 | else |
634 | 672 | while ((n_read = mc_read (src_desc, buf, buf_size)) < 0) { |
| 673 | if ( ctx->skip_all ) |
| 674 | goto ret; |
635 | 675 | return_status = file_error ( |
636 | 676 | _(" Cannot read source file \"%s\" \n %s "), src_path); |
637 | 677 | if (return_status == FILE_RETRY) |
638 | 678 | continue; |
| 679 | if (return_status == FILE_SKIPALL) |
| 680 | ctx->skip_all = 1; |
| 681 | if (return_status == FILE_SKIP); |
639 | 682 | goto ret; |
640 | 683 | } |
641 | 684 | if (n_read == 0) |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
658 | 701 | /* dst_write */ |
659 | 702 | while ((n_written = |
660 | 703 | mc_write (dest_desc, t, n_read)) < n_read) { |
| 704 | if ( ctx->skip_all ) |
| 705 | break; |
661 | 706 | if (n_written > 0) { |
662 | 707 | n_read -= n_written; |
663 | 708 | t += n_written; |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
668 | 713 | dst_path); |
669 | 714 | if (return_status != FILE_RETRY) |
670 | 715 | goto ret; |
| 716 | if (return_status == FILE_SKIPALL) |
| 717 | ctx->skip_all = 1; |
| 718 | if (return_status == FILE_SKIP) |
| 719 | break; |
671 | 720 | } |
672 | 721 | } |
673 | 722 | |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
725 | 774 | g_free (buf); |
726 | 775 | |
727 | 776 | while (src_desc != -1 && mc_close (src_desc) < 0) { |
| 777 | if ( ctx->skip_all ) |
| 778 | break; |
728 | 779 | temp_status = file_error ( |
729 | 780 | _(" Cannot close source file \"%s\" \n %s "), src_path); |
730 | 781 | if (temp_status == FILE_RETRY) |
731 | 782 | continue; |
732 | 783 | if (temp_status == FILE_ABORT) |
733 | 784 | return_status = temp_status; |
| 785 | if (temp_status == FILE_SKIPALL) |
| 786 | ctx->skip_all = 1; |
| 787 | if (temp_status == FILE_SKIP); |
734 | 788 | break; |
735 | 789 | } |
736 | 790 | |
737 | 791 | while (dest_desc != -1 && mc_close (dest_desc) < 0) { |
| 792 | if ( ctx->skip_all ) |
| 793 | break; |
738 | 794 | temp_status = file_error ( |
739 | 795 | _(" Cannot close target file \"%s\" \n %s "), dst_path); |
740 | 796 | if (temp_status == FILE_RETRY) |
741 | 797 | continue; |
| 798 | if (temp_status == FILE_SKIPALL) |
| 799 | ctx->skip_all = 1; |
| 800 | if (temp_status == FILE_SKIP); |
742 | 801 | return_status = temp_status; |
743 | 802 | break; |
744 | 803 | } |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
755 | 814 | /* Copy has succeeded */ |
756 | 815 | if (!appending && ctx->preserve_uidgid) { |
757 | 816 | while (mc_chown (dst_path, src_uid, src_gid)) { |
| 817 | if ( ctx->skip_all ) |
| 818 | break; |
758 | 819 | temp_status = file_error ( |
759 | 820 | _(" Cannot chown target file \"%s\" \n %s "), dst_path); |
760 | 821 | if (temp_status == FILE_RETRY) |
761 | 822 | continue; |
762 | | return_status = temp_status; |
| 823 | if (temp_status == FILE_SKIPALL) { |
| 824 | ctx->skip_all = 1; |
| 825 | return_status = FILE_CONT; |
| 826 | } |
| 827 | if (temp_status == FILE_SKIP) |
| 828 | return_status = FILE_CONT; |
763 | 829 | break; |
764 | 830 | } |
765 | 831 | } |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
767 | 833 | if (!appending) { |
768 | 834 | if (ctx->preserve){ |
769 | 835 | while (mc_chmod (dst_path, (src_mode & ctx->umask_kill))) { |
| 836 | if ( ctx->skip_all ) |
| 837 | break; |
770 | 838 | temp_status = file_error ( |
771 | 839 | _(" Cannot chmod target file \"%s\" \n %s "), dst_path); |
772 | | if (temp_status != FILE_RETRY) { |
773 | | return_status = temp_status; |
774 | | break; |
775 | | } |
| 840 | if (temp_status == FILE_RETRY) |
| 841 | continue; |
| 842 | if (temp_status == FILE_SKIPALL){ |
| 843 | ctx->skip_all = 1; |
| 844 | return_status = FILE_CONT; |
| 845 | } |
| 846 | if (temp_status == FILE_SKIP) |
| 847 | return_status = FILE_CONT; |
| 848 | break; |
776 | 849 | } |
777 | 850 | } else { |
778 | 851 | src_mode = umask(-1); |
… |
… |
erase_file (FileOpContext *ctx, const ch |
1256 | 1329 | } |
1257 | 1330 | |
1258 | 1331 | while (mc_unlink (s)) { |
| 1332 | if ( ctx->skip_all ) |
| 1333 | break; |
1259 | 1334 | return_status = |
1260 | 1335 | file_error (_(" Cannot delete file \"%s\" \n %s "), s); |
1261 | | if (return_status != FILE_RETRY) |
| 1336 | if (return_status == FILE_ABORT) |
1262 | 1337 | return return_status; |
| 1338 | if (return_status == FILE_RETRY) |
| 1339 | continue; |
| 1340 | if (return_status == FILE_SKIPALL) |
| 1341 | ctx->skip_all = 1; |
| 1342 | if (return_status == FILE_SKIP); |
| 1343 | break; |
1263 | 1344 | } |
1264 | 1345 | |
1265 | 1346 | if (progress_count) |
… |
… |
erase_file (FileOpContext *ctx, const ch |
1269 | 1350 | return FILE_CONT; |
1270 | 1351 | } |
1271 | 1352 | |
| 1353 | /* recursive remove of files |
| 1354 | abort->cancel stack |
| 1355 | skip ->warn every level, gets default |
| 1356 | skipall->remove as much as possible |
| 1357 | */ |
1272 | 1358 | static FileProgressStatus |
1273 | 1359 | recursive_erase (FileOpContext *ctx, const char *s, off_t *progress_count, |
1274 | 1360 | double *progress_bytes) |
… |
… |
recursive_erase (FileOpContext *ctx, con |
1287 | 1373 | if (!reading) |
1288 | 1374 | return FILE_RETRY; |
1289 | 1375 | |
1290 | | while ((next = mc_readdir (reading)) && return_status == FILE_CONT) { |
| 1376 | while ((next = mc_readdir (reading)) && !(return_status == FILE_ABORT) ) { |
1291 | 1377 | if (!strcmp (next->d_name, ".")) |
1292 | 1378 | continue; |
1293 | 1379 | if (!strcmp (next->d_name, "..")) |
… |
… |
recursive_erase (FileOpContext *ctx, con |
1300 | 1386 | } |
1301 | 1387 | if (S_ISDIR (buf.st_mode)) |
1302 | 1388 | return_status = |
1303 | | (recursive_erase |
1304 | | (ctx, path, progress_count, progress_bytes) |
1305 | | != FILE_CONT) ? FILE_RETRY : FILE_CONT; |
| 1389 | recursive_erase(ctx, path, progress_count, progress_bytes); |
1306 | 1390 | else |
1307 | 1391 | return_status = |
1308 | 1392 | erase_file (ctx, path, progress_count, progress_bytes, 0); |
1309 | 1393 | g_free (path); |
1310 | 1394 | } |
1311 | 1395 | mc_closedir (reading); |
1312 | | if (return_status != FILE_CONT) |
| 1396 | if (return_status == FILE_ABORT) |
1313 | 1397 | return return_status; |
1314 | 1398 | if (file_progress_show_deleting (ctx, s) == FILE_ABORT) |
1315 | 1399 | return FILE_ABORT; |
1316 | 1400 | mc_refresh (); |
1317 | 1401 | |
1318 | 1402 | while (my_rmdir (s)) { |
| 1403 | if ( ctx->skip_all ) |
| 1404 | break; |
1319 | 1405 | return_status = |
1320 | 1406 | file_error (_(" Cannot remove directory \"%s\" \n %s "), s); |
1321 | | if (return_status != FILE_RETRY) |
| 1407 | if (return_status == FILE_RETRY) |
| 1408 | continue; |
| 1409 | if (return_status == FILE_ABORT) |
1322 | 1410 | return return_status; |
| 1411 | if (return_status == FILE_SKIPALL) |
| 1412 | ctx->skip_all = 1; |
| 1413 | if (return_status == FILE_SKIP); |
| 1414 | break; |
1323 | 1415 | } |
1324 | 1416 | |
1325 | 1417 | return FILE_CONT; |
… |
… |
real_do_file_error (enum OperationMode m |
2252 | 2344 | |
2253 | 2345 | msg = mode == Foreground ? MSG_ERROR : _(" Background process error "); |
2254 | 2346 | result = |
2255 | | query_dialog (msg, error, D_ERROR, 3, _("&Skip"), _("&Retry"), |
| 2347 | query_dialog (msg, error, D_ERROR, 3, _("&Skip"),("Ski&p All"), _("&Retry"), |
2256 | 2348 | _("&Abort")); |
2257 | 2349 | |
2258 | 2350 | switch (result) { |
… |
… |
real_do_file_error (enum OperationMode m |
2262 | 2354 | |
2263 | 2355 | case 1: |
2264 | 2356 | do_refresh (); |
2265 | | return FILE_RETRY; |
| 2357 | return FILE_SKIPALL; |
2266 | 2358 | |
2267 | 2359 | case 2: |
| 2360 | do_refresh (); |
| 2361 | return FILE_RETRY; |
| 2362 | |
| 2363 | case 3: |
2268 | 2364 | default: |
2269 | 2365 | return FILE_ABORT; |
2270 | 2366 | } |
diff -pruN mc-4.7.0.8-orig/src/fileopctx.c mc-4.7.0.8/src/fileopctx.c
old
|
new
|
file_op_context_new (FileOperation op) |
61 | 61 | ctx->preserve_uidgid = (geteuid () == 0) ? TRUE : FALSE; |
62 | 62 | ctx->umask_kill = 0777777; |
63 | 63 | ctx->erase_at_end = TRUE; |
64 | | |
| 64 | ctx->skip_all = 0; |
65 | 65 | return ctx; |
66 | 66 | } |
67 | 67 | |
diff -pruN mc-4.7.0.8-orig/src/fileopctx.h mc-4.7.0.8/src/fileopctx.h
old
|
new
|
typedef struct FileOpContext { |
107 | 107 | |
108 | 108 | /* PID of the child for background operations */ |
109 | 109 | pid_t pid; |
| 110 | |
| 111 | /* toggle if all errors should be ignored */ |
| 112 | int skip_all; |
110 | 113 | |
111 | 114 | /* User interface data goes here */ |
112 | 115 | |
… |
… |
void file_op_context_destroy (FileOpCont |
121 | 124 | extern const char *op_names [3]; |
122 | 125 | |
123 | 126 | typedef enum { |
124 | | FILE_CONT = 0, |
125 | | FILE_RETRY = 1, |
126 | | FILE_SKIP = 2, |
127 | | FILE_ABORT = 3 |
| 127 | FILE_CONT = 0, |
| 128 | FILE_RETRY = 1, |
| 129 | FILE_SKIP = 2, |
| 130 | FILE_ABORT = 3, |
| 131 | FILE_SKIPALL = 4 |
128 | 132 | } FileProgressStatus; |
129 | 133 | |
130 | 134 | typedef enum { |