Ticket #71: mc-4.6.1-skipall.patch

File mc-4.6.1-skipall.patch, 10.3 KB (added by ZlatkO, 14 years ago)

original patch against 4.6.1-CVS

  • src/file.c

    diff -pru mc-4.6.1-orig/src/file.c mc-4.6.1/src/file.c
    old new copy_file_file (FileOpContext *ctx, cons 
    548548                S_ISSOCK (sb.st_mode)) { 
    549549            while (mc_mknod (dst_path, sb.st_mode & ctx->umask_kill, 
    550550                    sb.st_rdev) < 0) { 
     551                if ( ctx->skip_all ) 
     552                    break; 
    551553                return_status = file_error ( 
    552554                    _(" Cannot create special file \"%s\" \n %s "), dst_path); 
    553555                if (return_status == FILE_RETRY) 
    554556                    continue; 
     557                if (return_status == FILE_SKIPALL) 
     558                    ctx->skip_all = 1; 
     559                if (return_status == FILE_SKIP); 
    555560                return return_status; 
    556561            } 
    557562            /* Success */ 
    558563 
    559564            while (ctx->preserve_uidgid 
    560565                   && mc_chown (dst_path, sb.st_uid, sb.st_gid)) { 
     566                if ( ctx->skip_all ) 
     567                    break; 
    561568                temp_status = file_error ( 
    562569                        _(" Cannot chown target file \"%s\" \n %s "), dst_path); 
     570                if (temp_status == FILE_SKIPALL) 
     571                    ctx->skip_all = 1; 
     572                if (temp_status == FILE_SKIP) 
     573                    break; 
    563574                if (temp_status == FILE_RETRY) 
    564575                    continue; 
    565576                return temp_status; 
    566577            } 
    567578            while (ctx->preserve && 
    568579                   mc_chmod (dst_path, sb.st_mode & ctx->umask_kill)) { 
     580                if ( ctx->skip_all ) 
     581                    break; 
    569582                temp_status = file_error ( 
    570583                        _(" Cannot chmod target file \"%s\" \n %s "), dst_path); 
     584                if (temp_status == FILE_SKIPALL) 
     585                    ctx->skip_all = 1; 
     586                if (temp_status == FILE_SKIP) 
     587                    break; 
    571588                if (temp_status == FILE_RETRY) 
    572589                    continue; 
    573590                return temp_status; 
    copy_file_file (FileOpContext *ctx, cons 
    579596    gettimeofday (&tv_transfer_start, (struct timezone *) NULL); 
    580597 
    581598    while ((src_desc = mc_open (src_path, O_RDONLY | O_LINEAR)) < 0) { 
     599        if ( ctx->skip_all ) 
     600            break; 
    582601        return_status = file_error ( 
    583602                _(" Cannot open source file \"%s\" \n %s "), src_path); 
    584603        if (return_status == FILE_RETRY) 
    585604            continue; 
     605        if (return_status == FILE_SKIPALL) 
     606            ctx->skip_all = 1; 
     607        if (return_status == FILE_SKIP) 
     608            break; 
    586609        ctx->do_append = 0; 
    587610        return return_status; 
    588611    } 
    copy_file_file (FileOpContext *ctx, cons 
    596619    } 
    597620 
    598621    while (mc_fstat (src_desc, &sb)) { 
     622        if ( ctx->skip_all ) 
     623            goto ret; 
    599624        return_status = file_error ( 
    600625                _(" Cannot fstat source file \"%s\" \n %s "), src_path); 
    601626        if (return_status == FILE_RETRY) 
    602627            continue; 
     628        if (return_status == FILE_SKIPALL) 
     629            ctx->skip_all = 1; 
     630        if (return_status == FILE_SKIP); 
    603631        ctx->do_append = 0; 
    604632        goto ret; 
    605633    } 
    copy_file_file (FileOpContext *ctx, cons 
    616644 
    617645    while ((dest_desc = mc_open (dst_path, O_WRONLY | (ctx->do_append ? 
    618646            O_APPEND : (O_CREAT | O_TRUNC)), 0600)) < 0) { 
     647        if ( ctx->skip_all ) 
     648            goto ret; 
    619649        return_status = file_error ( 
    620650                _(" Cannot create target file \"%s\" \n %s "), dst_path); 
    621651        if (return_status == FILE_RETRY) 
    622652            continue; 
     653        if (return_status == FILE_SKIPALL) 
     654            ctx->skip_all = 1; 
     655        if (return_status == FILE_SKIP); 
    623656        ctx->do_append = 0; 
    624657        goto ret; 
    625658    } 
    copy_file_file (FileOpContext *ctx, cons 
    630663 
    631664    /* Find out the optimal buffer size.  */ 
    632665    while (mc_fstat (dest_desc, &sb)) { 
     666        if ( ctx->skip_all ) 
     667            goto ret; 
    633668        return_status = file_error ( 
    634669                _(" Cannot fstat target file \"%s\" \n %s "), dst_path); 
    635670        if (return_status == FILE_RETRY) 
    636671            continue; 
     672        if (return_status == FILE_SKIPALL) 
     673            ctx->skip_all = 1; 
     674        if (return_status == FILE_SKIP); 
    637675        goto ret; 
    638676    } 
    639677    buf = g_malloc (buf_size); 
    copy_file_file (FileOpContext *ctx, cons 
    662700                n_read = -1; 
    663701            else 
    664702                while ((n_read = mc_read (src_desc, buf, buf_size)) < 0) { 
     703                    if ( ctx->skip_all ) 
     704                        goto ret; 
    665705                    return_status = file_error ( 
    666706                        _(" Cannot read source file \"%s\" \n %s "), src_path); 
    667707                    if (return_status == FILE_RETRY) 
    668708                        continue; 
     709                    if (return_status == FILE_SKIPALL) 
     710                        ctx->skip_all = 1; 
     711                    if (return_status == FILE_SKIP); 
    669712                    goto ret; 
    670713                } 
    671714            if (n_read == 0) 
    copy_file_file (FileOpContext *ctx, cons 
    688731                /* dst_write */ 
    689732                while ((n_written = 
    690733                        mc_write (dest_desc, t, n_read)) < n_read) { 
     734                    if ( ctx->skip_all ) 
     735                        break; 
    691736                    if (n_written > 0) { 
    692737                        n_read -= n_written; 
    693738                        t += n_written; 
    copy_file_file (FileOpContext *ctx, cons 
    698743                                dst_path); 
    699744                    if (return_status != FILE_RETRY) 
    700745                        goto ret; 
     746                    if (return_status == FILE_SKIPALL) 
     747                        ctx->skip_all = 1; 
     748                    if (return_status == FILE_SKIP) 
     749                        break; 
    701750                } 
    702751            } 
    703752 
    copy_file_file (FileOpContext *ctx, cons 
    755804    g_free (buf); 
    756805 
    757806    while (src_desc != -1 && mc_close (src_desc) < 0) { 
     807        if ( ctx->skip_all ) 
     808            break; 
    758809        temp_status = file_error ( 
    759810                _(" Cannot close source file \"%s\" \n %s "), src_path); 
    760811        if (temp_status == FILE_RETRY) 
    761812            continue; 
    762813        if (temp_status == FILE_ABORT) 
    763814            return_status = temp_status; 
     815        if (temp_status == FILE_SKIPALL) 
     816            ctx->skip_all = 1; 
     817        if (temp_status == FILE_SKIP); 
    764818        break; 
    765819    } 
    766820 
    767821    while (dest_desc != -1 && mc_close (dest_desc) < 0) { 
     822        if ( ctx->skip_all ) 
     823            break; 
    768824        temp_status = file_error ( 
    769825                _(" Cannot close target file \"%s\" \n %s "), dst_path); 
    770826        if (temp_status == FILE_RETRY) 
    771827            continue; 
     828        if (temp_status == FILE_SKIPALL) 
     829            ctx->skip_all = 1; 
     830        if (temp_status == FILE_SKIP); 
    772831        return_status = temp_status; 
    773832        break; 
    774833    } 
    copy_file_file (FileOpContext *ctx, cons 
    785844        /* Copy has succeeded */ 
    786845        if (!appending && ctx->preserve_uidgid) { 
    787846            while (mc_chown (dst_path, src_uid, src_gid)) { 
     847                if ( ctx->skip_all ) 
     848                    break; 
    788849                temp_status = file_error ( 
    789850                        _(" Cannot chown target file \"%s\" \n %s "), dst_path); 
    790851                if (temp_status == FILE_RETRY) 
    791852                    continue; 
    792                 return_status = temp_status; 
     853                if (temp_status == FILE_SKIPALL) { 
     854                    ctx->skip_all = 1; 
     855                    return_status = FILE_CONT; 
     856                } 
     857                if (temp_status == FILE_SKIP) 
     858                    return_status = FILE_CONT; 
    793859                break; 
    794860            } 
    795861        } 
    796862 
    797863        if (!appending && ctx->preserve) { 
    798864            while (mc_chmod (dst_path, (src_mode & ctx->umask_kill))) { 
     865                if ( ctx->skip_all ) 
     866                    break; 
    799867                temp_status = file_error ( 
    800868                        _(" Cannot chmod target file \"%s\" \n %s "), dst_path); 
    801                 if (temp_status != FILE_RETRY) { 
    802                     return_status = temp_status; 
    803                     break; 
     869                if (temp_status == FILE_RETRY) 
     870                    continue; 
     871                if (temp_status == FILE_SKIPALL){ 
     872                    ctx->skip_all = 1; 
     873                    return_status = FILE_CONT; 
    804874                } 
     875                if (temp_status == FILE_SKIP) 
     876                    return_status = FILE_CONT; 
     877                break; 
    805878            } 
    806879            mc_utime (dst_path, &utb); 
    807880        } 
    erase_file (FileOpContext *ctx, const ch 
    12911364    } 
    12921365 
    12931366    while (mc_unlink (s)) { 
     1367        if ( ctx->skip_all ) 
     1368            break; 
    12941369        return_status = 
    12951370            file_error (_(" Cannot delete file \"%s\" \n %s "), s); 
    1296         if (return_status != FILE_RETRY) 
     1371        if (return_status == FILE_ABORT) 
    12971372            return return_status; 
     1373        if (return_status == FILE_RETRY) 
     1374            continue; 
     1375        if (return_status == FILE_SKIPALL)  
     1376            ctx->skip_all = 1; 
     1377        if (return_status == FILE_SKIP); 
     1378        break; 
    12981379    } 
    1299  
    13001380    if (progress_count) 
    13011381        return progress_update_one (ctx, progress_count, progress_bytes, 
    13021382                                    buf.st_size, is_toplevel_file); 
    13031383    else 
    13041384        return FILE_CONT; 
    13051385} 
    1306  
     1386/* recursive remove of files 
     1387  abort->cancel stack 
     1388  skip ->warn every level, gets default 
     1389  skipall->remove as much as possible 
     1390 */ 
    13071391static int 
    13081392recursive_erase (FileOpContext *ctx, const char *s, off_t *progress_count, 
    13091393                 double *progress_bytes) 
    recursive_erase (FileOpContext *ctx, con 
    13221406    if (!reading) 
    13231407        return 1; 
    13241408 
    1325     while ((next = mc_readdir (reading)) && return_status == FILE_CONT) { 
     1409    while ((next = mc_readdir (reading)) && !(return_status == FILE_ABORT) ) { 
    13261410        if (!strcmp (next->d_name, ".")) 
    13271411            continue; 
    13281412        if (!strcmp (next->d_name, "..")) 
    recursive_erase (FileOpContext *ctx, con 
    13341418            return 1; 
    13351419        } 
    13361420        if (S_ISDIR (buf.st_mode)) 
    1337             return_status = 
    1338                 (recursive_erase 
    1339                  (ctx, path, progress_count, progress_bytes) 
    1340                  != FILE_CONT); 
     1421            return_status =  
     1422                recursive_erase(ctx, path, progress_count, progress_bytes); 
    13411423        else 
    13421424            return_status = 
    13431425                erase_file (ctx, path, progress_count, progress_bytes, 0); 
    13441426        g_free (path); 
    13451427    } 
    13461428    mc_closedir (reading); 
    1347     if (return_status != FILE_CONT) 
     1429    if (return_status == FILE_ABORT) 
    13481430        return return_status; 
    13491431    if (file_progress_show_deleting (ctx, s) == FILE_ABORT) 
    13501432        return FILE_ABORT; 
    13511433    mc_refresh (); 
    13521434 
    13531435    while (my_rmdir (s)) { 
     1436        if ( ctx->skip_all ) 
     1437            break; 
    13541438        return_status = 
    13551439            file_error (_(" Cannot remove directory \"%s\" \n %s "), s); 
    1356         if (return_status != FILE_RETRY) 
     1440        if (return_status == FILE_RETRY) 
     1441            continue; 
     1442        if (return_status == FILE_ABORT) 
    13571443            return return_status; 
     1444        if (return_status == FILE_SKIPALL) 
     1445            ctx->skip_all = 1; 
     1446        if (return_status == FILE_SKIP); 
     1447        break; 
    13581448    } 
    13591449 
    13601450    return FILE_CONT; 
    real_do_file_error (enum OperationMode m 
    20752165 
    20762166    msg = mode == Foreground ? MSG_ERROR : _(" Background process error "); 
    20772167    result = 
    2078         query_dialog (msg, error, D_ERROR, 3, _("&Skip"), _("&Retry"), 
     2168        query_dialog (msg, error, D_ERROR, 3, _("&Skip"),("Ski&p All"), _("&Retry"), 
    20792169                      _("&Abort")); 
    20802170 
    20812171    switch (result) { 
    real_do_file_error (enum OperationMode m 
    20852175 
    20862176    case 1: 
    20872177        do_refresh (); 
    2088         return FILE_RETRY; 
     2178        return FILE_SKIPALL; 
    20892179 
    20902180    case 2: 
     2181        do_refresh (); 
     2182        return FILE_RETRY; 
     2183 
     2184    case 3: 
    20912185    default: 
    20922186        return FILE_ABORT; 
    20932187    } 
  • src/fileopctx.c

    diff -pru mc-4.6.1-orig/src/fileopctx.c mc-4.6.1/src/fileopctx.c
    old new file_op_context_new (FileOperation op) 
    5151    ctx->preserve_uidgid = (geteuid () == 0) ? TRUE : FALSE; 
    5252    ctx->umask_kill = 0777777; 
    5353    ctx->erase_at_end = TRUE; 
    54  
     54    ctx->skip_all = 0; 
    5555    return ctx; 
    5656} 
    5757 
  • src/fileopctx.h

    diff -pru mc-4.6.1-orig/src/fileopctx.h mc-4.6.1/src/fileopctx.h
    old new typedef struct FileOpContext { 
    104104 
    105105        /* PID of the child for background operations */ 
    106106        pid_t pid; 
     107         
     108        /* toggle if all errors should be ignored */ 
     109        int skip_all; 
    107110 
    108111        /* User interface data goes here */ 
    109112 
    typedef enum { 
    121124        FILE_CONT, 
    122125        FILE_RETRY, 
    123126        FILE_SKIP, 
    124         FILE_ABORT 
     127        FILE_ABORT, 
     128        FILE_SKIPALL 
    125129} FileProgressStatus; 
    126130 
    127131typedef enum {