Changeset 146699 for trunk/base


Ignore:
Timestamp:
Mar 15, 2016, 3:43:50 PM (4 years ago)
Author:
cal@…
Message:

base: reclaim: Fix signals being swallowed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/macports1.0/reclaim.tcl

    r146694 r146699  
    138138
    139139            # Get mport reference
    140             if {[catch {set mport [mportopen_installed $name $version $revision $variants {}]} error]} {
     140            try -pass_signal {
     141                set mport [mportopen_installed $name $version $revision $variants {}]
     142            } catch {{*} eCode eMessage} {
    141143                $progress intermission
    142                 ui_warn [msgcat::mc "Failed to open port %s from registry: %s" $name $error]
     144                ui_warn [msgcat::mc "Failed to open port %s from registry: %s" $name $eMessage]
    143145                continue
    144146            }
     
    208210                            set home_length [string length "${home_dist}/"]
    209211
    210                             try {
     212                            try -pass_signal {
    211213                                ui_info [msgcat::mc "Deleting unused file %s" $f]
    212214                                file delete -- $f
     
    226228
    227229                                    ui_info [msgcat::mc "Deleting empty directory %s" $directory]
    228                                     try {
     230                                    try -pass_signal {
    229231                                        file delete -- $directory
    230232                                    } catch {{*} eCode eMessage} {
     
    259261    }
    260262
    261     proc close_file {file} {
    262 
    263         # Closes the file, handling error catching if needed.
    264         #
    265         # Args:
    266         #           file - The file handler
    267         # Returns:
    268         #           None
    269         if {[catch {close $file} error]} {
    270             ui_error "something went wrong when closing file, $file."
    271         }
    272     }
    273 
    274263    proc is_inactive {port} {
    275264
     
    299288        #           Indexes of each sublist are: 0 = name, 1 = version, 2 = revision, 3 = variants, 4 = activity, and 5 = epoch.
    300289       
    301         if {[catch {set installed [registry::installed]} result]} {
     290        try -pass_signal {
     291            return [registry::installed]
     292        } catch {*} {
    302293            ui_error "no installed ports found."
    303294            return {}
    304295        }
    305 
    306         return $installed
    307296    }
    308297
     
    318307        ui_debug "Updating last run information."
    319308
    320         set path    [file join ${macports::portdbpath} last_reclaim]
    321         set fd      [open $path w]
    322         puts $fd    [clock seconds]
    323         close_file $fd
     309        set path [file join ${macports::portdbpath} last_reclaim]
     310        set fd -1
     311        try -pass_signal {
     312            set fd [open $path w]
     313            puts $fd [clock seconds]
     314        } finally {
     315            if {$fd != -1} {
     316                close $fd
     317            }
     318        }
    324319    }
    325320
     
    337332        set path [file join ${macports::portdbpath} last_reclaim]
    338333
    339         if {[file exists $path]} {
    340 
    341             set fd      [open $path r]
    342             set time    [gets $fd]
    343             close_file $fd
    344 
    345             if {$time ne ""} {
    346                 if {[clock seconds] - $time > 1209600} {
    347                     ui_warn "You haven't run 'port reclaim' in two weeks. It's recommended you run this every two weeks to reclaim disk space."
    348                 }
     334        set fd -1
     335        set time ""
     336        try -pass_signal {
     337            set fd [open $path r]
     338            set time [gets $fd]
     339        } finally {
     340            if {$fd != -1} {
     341                close $fd
     342            }
     343        }
     344        if {$time ne ""} {
     345            if {[clock seconds] - $time > 1209600} {
     346                ui_warn "You haven't run 'port reclaim' in two weeks. It's recommended you run this every two weeks to reclaim disk space."
    349347            }
    350348        }
     
    393391
    394392                        # Note: 'uninstall' takes a name, version, revision, variants and an options list.
    395                         if {[catch {registry_uninstall::uninstall $name [lindex $port 1] [lindex $port 2] [lindex $port 3] {}} error]} {
    396                             ui_error "something went wrong when uninstalling $name"
     393                        try -pass_signal {
     394                            registry_uninstall::uninstall $name [lindex $port 1] [lindex $port 2] [lindex $port 3] {}
     395                        } catch {{*} eCode eMessage} {
     396                            ui_error "Error uninstalling $name: $eMessage"
    397397                        }
    398398                    }
Note: See TracChangeset for help on using the changeset viewer.