Ticket #71: mc-4.7.5.1-skipall.diff

File mc-4.7.5.1-skipall.diff, 12.1 KB (added by ZlatkO, 13 years ago)

updated and cleaned up patch for 4.7.5.1

  • src/filemanager/file.c

    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 
    674674 
    675675    while (mc_unlink (s) != 0) 
    676676    { 
     677        if ( ctx->skip_all ) 
     678            break; 
    677679        return_status = file_error (_("Cannot delete file \"%s\"\n%s"), s); 
    678         if (return_status != FILE_RETRY) 
     680        if (return_status == FILE_ABORT) 
    679681            return return_status; 
     682        if (return_status == FILE_RETRY) 
     683            continue; 
     684        if (return_status == FILE_SKIPALL) 
     685            ctx->skip_all = 1; 
     686        break; 
    680687    } 
    681688 
    682689    if (tctx->progress_count == 0) 
    erase_file (FileOpTotalContext * tctx, F 
    686693 
    687694/* --------------------------------------------------------------------------------------------- */ 
    688695 
     696/* recursive remove of files 
     697  abort->cancel stack 
     698  skip ->warn every level, gets default 
     699  skipall->remove as much as possible 
     700 */ 
    689701static FileProgressStatus 
    690702recursive_erase (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s) 
    691703{ 
    recursive_erase (FileOpTotalContext * tc 
    703715    if (!reading) 
    704716        return FILE_RETRY; 
    705717 
    706     while ((next = mc_readdir (reading)) && return_status == FILE_CONT) 
     718    while ((next = mc_readdir (reading)) && !(return_status == FILE_ABORT)) 
    707719    { 
    708720        if (!strcmp (next->d_name, ".")) 
    709721            continue; 
    recursive_erase (FileOpTotalContext * tc 
    718730        } 
    719731        if (S_ISDIR (buf.st_mode)) 
    720732            return_status = 
    721                 (recursive_erase (tctx, ctx, path) != FILE_CONT) ? FILE_RETRY : FILE_CONT; 
     733                recursive_erase (tctx, ctx, path); 
    722734        else 
    723735            return_status = erase_file (tctx, ctx, path, 0); 
    724736        g_free (path); 
    725737    } 
    726738    mc_closedir (reading); 
    727     if (return_status != FILE_CONT) 
     739    if (return_status == FILE_ABORT) 
    728740        return return_status; 
    729741    file_progress_show_deleting (ctx, s); 
    730742    if (check_progress_buttons (ctx) == FILE_ABORT) 
    recursive_erase (FileOpTotalContext * tc 
    733745 
    734746    while (my_rmdir (s)) 
    735747    { 
     748        if ( ctx->skip_all ) 
     749            break; 
    736750        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) 
    738754            return return_status; 
     755        if (return_status == FILE_SKIPALL) 
     756            ctx->skip_all = 1; 
     757        break; 
    739758    } 
    740759 
    741760    return FILE_CONT; 
    real_do_file_error (enum OperationMode m 
    10691088    const char *msg; 
    10701089 
    10711090    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")); 
    10731092 
    10741093    switch (result) 
    10751094    { 
    real_do_file_error (enum OperationMode m 
    10791098 
    10801099    case 1: 
    10811100        do_refresh (); 
    1082         return FILE_RETRY; 
     1101        return FILE_SKIPALL; 
    10831102 
    10841103    case 2: 
     1104        do_refresh (); 
     1105        return FILE_RETRY; 
     1106 
     1107    case 3: 
    10851108    default: 
    10861109        return FILE_ABORT; 
    10871110    } 
    copy_file_file (FileOpTotalContext * tct 
    13211344        { 
    13221345            while (mc_mknod (dst_path, sb.st_mode & ctx->umask_kill, sb.st_rdev) < 0) 
    13231346            { 
     1347                if ( ctx->skip_all ) 
     1348                    break; 
    13241349                return_status = file_error (_("Cannot create special file \"%s\"\n%s"), dst_path); 
    13251350                if (return_status == FILE_RETRY) 
    13261351                    continue; 
     1352                if (return_status == FILE_SKIPALL) 
     1353                    ctx->skip_all = 1; 
    13271354                return return_status; 
    13281355            } 
    13291356            /* Success */ 
    13301357 
    13311358            while (ctx->preserve_uidgid && mc_chown (dst_path, sb.st_uid, sb.st_gid)) 
    13321359            { 
     1360                if ( ctx->skip_all ) 
     1361                    break; 
    13331362                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; 
    13341367                if (temp_status == FILE_RETRY) 
    13351368                    continue; 
    13361369                return temp_status; 
    13371370            } 
    13381371            while (ctx->preserve && mc_chmod (dst_path, sb.st_mode & ctx->umask_kill)) 
    13391372            { 
     1373                if ( ctx->skip_all ) 
     1374                    break; 
    13401375                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; 
    13411380                if (temp_status == FILE_RETRY) 
    13421381                    continue; 
    13431382                return temp_status; 
    copy_file_file (FileOpTotalContext * tct 
    13501389 
    13511390    while ((src_desc = mc_open (src_path, O_RDONLY | O_LINEAR)) < 0) 
    13521391    { 
     1392        if ( ctx->skip_all ) 
     1393            break; 
    13531394        return_status = file_error (_("Cannot open source file \"%s\"\n%s"), src_path); 
    13541395        if (return_status == FILE_RETRY) 
    13551396            continue; 
     1397        if (return_status == FILE_SKIPALL) 
     1398            ctx->skip_all = 1; 
     1399        if (return_status == FILE_SKIP) 
     1400            break; 
    13561401        ctx->do_append = 0; 
    13571402        return return_status; 
    13581403    } 
    copy_file_file (FileOpTotalContext * tct 
    13691414 
    13701415    while (mc_fstat (src_desc, &sb)) 
    13711416    { 
     1417        if ( ctx->skip_all ) 
     1418            goto ret; 
    13721419        return_status = file_error (_("Cannot fstat source file \"%s\"\n%s"), src_path); 
    13731420        if (return_status == FILE_RETRY) 
    13741421            continue; 
     1422        if (return_status == FILE_SKIPALL) 
     1423            ctx->skip_all = 1; 
    13751424        ctx->do_append = FALSE; 
    13761425        goto ret; 
    13771426    } 
    copy_file_file (FileOpTotalContext * tct 
    13991448    { 
    14001449        if (errno == EEXIST) 
    14011450            goto ret; 
     1451        if ( ctx->skip_all ) 
     1452            goto ret; 
    14021453 
    14031454        return_status = file_error (_("Cannot create target file \"%s\"\n%s"), dst_path); 
    14041455        if (return_status == FILE_RETRY) 
    14051456            continue; 
     1457        if (return_status == FILE_SKIPALL) 
     1458            ctx->skip_all = 1; 
    14061459        ctx->do_append = FALSE; 
    14071460        goto ret; 
    14081461    } 
    copy_file_file (FileOpTotalContext * tct 
    14141467    /* Find out the optimal buffer size.  */ 
    14151468    while (mc_fstat (dest_desc, &sb)) 
    14161469    { 
     1470        if ( ctx->skip_all ) 
     1471            goto ret; 
    14171472        return_status = file_error (_("Cannot fstat target file \"%s\"\n%s"), dst_path); 
    14181473        if (return_status == FILE_RETRY) 
    14191474            continue; 
     1475        if (return_status == FILE_SKIPALL) 
     1476            ctx->skip_all = 1; 
    14201477        goto ret; 
    14211478    } 
    14221479 
    copy_file_file (FileOpTotalContext * tct 
    14501507            else 
    14511508                while ((n_read = mc_read (src_desc, buf, sizeof (buf))) < 0) 
    14521509                { 
     1510                    if ( ctx->skip_all ) 
     1511                        goto ret; 
    14531512                    return_status = file_error (_("Cannot read source file\"%s\"\n%s"), src_path); 
    14541513                    if (return_status == FILE_RETRY) 
    14551514                        continue; 
     1515                    if (return_status == FILE_SKIPALL) 
     1516                        ctx->skip_all = 1; 
    14561517                    goto ret; 
    14571518                } 
    14581519            if (n_read == 0) 
    copy_file_file (FileOpTotalContext * tct 
    14761537                /* dst_write */ 
    14771538                while ((n_written = mc_write (dest_desc, t, n_read)) < n_read) 
    14781539                { 
     1540                    if ( ctx->skip_all ) 
     1541                        break; 
    14791542                    if (n_written > 0) 
    14801543                    { 
    14811544                        n_read -= n_written; 
    copy_file_file (FileOpTotalContext * tct 
    14831546                        continue; 
    14841547                    } 
    14851548                    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; 
    14861553                    if (return_status != FILE_RETRY) 
    14871554                        goto ret; 
    14881555                } 
    copy_file_file (FileOpTotalContext * tct 
    15381605  ret: 
    15391606    while (src_desc != -1 && mc_close (src_desc) < 0) 
    15401607    { 
     1608        if ( ctx->skip_all ) 
     1609            break; 
    15411610        temp_status = file_error (_("Cannot close source file \"%s\"\n%s"), src_path); 
    15421611        if (temp_status == FILE_RETRY) 
    15431612            continue; 
    15441613        if (temp_status == FILE_ABORT) 
    15451614            return_status = temp_status; 
     1615        if (temp_status == FILE_SKIPALL) 
     1616            ctx->skip_all = 1; 
    15461617        break; 
    15471618    } 
    15481619 
    15491620    while (dest_desc != -1 && mc_close (dest_desc) < 0) 
    15501621    { 
     1622        if ( ctx->skip_all ) 
     1623            break; 
    15511624        temp_status = file_error (_("Cannot close target file \"%s\"\n%s"), dst_path); 
    15521625        if (temp_status == FILE_RETRY) 
    15531626            continue; 
     1627        if (temp_status == FILE_SKIPALL) 
     1628            ctx->skip_all = 1; 
    15541629        return_status = temp_status; 
    15551630        break; 
    15561631    } 
    copy_file_file (FileOpTotalContext * tct 
    15721647        { 
    15731648            while (mc_chown (dst_path, src_uid, src_gid)) 
    15741649            { 
     1650                if ( ctx->skip_all ) 
     1651                    break; 
    15751652                temp_status = file_error (_("Cannot chown target file \"%s\"\n%s"), dst_path); 
    15761653                if (temp_status == FILE_RETRY) 
    15771654                    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; 
    15791661                break; 
    15801662            } 
    15811663        } 
    copy_file_file (FileOpTotalContext * tct 
    15861668            { 
    15871669                while (mc_chmod (dst_path, (src_mode & ctx->umask_kill))) 
    15881670                { 
    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 ) 
    15931672                        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; 
    15941679                    } 
     1680                    if (temp_status == FILE_SKIP) 
     1681                        return_status = FILE_CONT; 
     1682                    break; 
    15951683                } 
    15961684            } 
    15971685            else 
  • src/filemanager/fileopctx.c

    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) 
    7878    ctx->preserve_uidgid = (geteuid () == 0); 
    7979    ctx->umask_kill = 0777777; 
    8080    ctx->erase_at_end = TRUE; 
     81    ctx->skip_all = 0; 
    8182 
    8283    return ctx; 
    8384} 
  • src/filemanager/fileopctx.h

    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 
    5656    FILE_CONT = 0, 
    5757    FILE_RETRY = 1, 
    5858    FILE_SKIP = 2, 
    59     FILE_ABORT = 3 
     59    FILE_ABORT = 3, 
     60    FILE_SKIPALL = 4 
    6061} FileProgressStatus; 
    6162 
    6263/* First argument passed to real functions */ 
    typedef struct FileOpContext 
    155156    /* PID of the child for background operations */ 
    156157    pid_t pid; 
    157158 
     159    /* toggle if all errors should be ignored */ 
     160    int skip_all; 
     161 
    158162    /* User interface data goes here */ 
    159163    void *ui; 
    160164} FileOpContext;