[125007] trunk/base
ksammons at macports.org
ksammons at macports.org
Tue Sep 2 10:47:55 PDT 2014
Revision: 125007
https://trac.macports.org/changeset/125007
Author: ksammons at macports.org
Date: 2014-09-02 10:47:55 -0700 (Tue, 02 Sep 2014)
Log Message:
-----------
base: Refactor distfile waking code in reclaim to avoid deleting outside the root path.
https://lists.macosforge.org/pipermail/macports-dev/2014-August/027811.html
Modified Paths:
--------------
trunk/base/doc/port-doctor.1
trunk/base/doc/port-reclaim.1
trunk/base/src/macports1.0/reclaim.tcl
Modified: trunk/base/doc/port-doctor.1
===================================================================
--- trunk/base/doc/port-doctor.1 2014-09-02 17:20:04 UTC (rev 125006)
+++ trunk/base/doc/port-doctor.1 2014-09-02 17:47:55 UTC (rev 125007)
@@ -1,5 +1,5 @@
'\" t
-.TH "PORT\-DOCTOR" "1" "08/24/2014" "MacPorts 2\&.3\&.99" "MacPorts Manual"
+.TH "PORT\-DOCTOR" "1" "09/02/2014" "MacPorts 2\&.3\&.99" "MacPorts Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
Modified: trunk/base/doc/port-reclaim.1
===================================================================
--- trunk/base/doc/port-reclaim.1 2014-09-02 17:20:04 UTC (rev 125006)
+++ trunk/base/doc/port-reclaim.1 2014-09-02 17:47:55 UTC (rev 125007)
@@ -1,5 +1,5 @@
'\" t
-.TH "PORT\-RECLAIM" "1" "08/24/2014" "MacPorts 2\&.3\&.99" "MacPorts Manual"
+.TH "PORT\-RECLAIM" "1" "09/02/2014" "MacPorts 2\&.3\&.99" "MacPorts Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
Modified: trunk/base/src/macports1.0/reclaim.tcl
===================================================================
--- trunk/base/src/macports1.0/reclaim.tcl 2014-09-02 17:20:04 UTC (rev 125006)
+++ trunk/base/src/macports1.0/reclaim.tcl 2014-09-02 17:47:55 UTC (rev 125007)
@@ -97,58 +97,40 @@
set root_dist [file join ${macports::portdbpath} distfiles]
set home_dist ${macports::user_home}/.macports/$root_dist
-
- # If the directory is empty, and this isn't the root folder, delete it and recursively go up directories until a non-empty one is found.
- if { $dir ne $root_dist && $dir ne $home_dist && [readdir $dir] eq ""} {
-
- set up_dir [file dirname $dir]
-
- ui_msg "Found empty directory: $dir. Attempting to delete."
-
- if {[catch {file delete -force $dir} error] } {
- ui_error "something went wrong when trying to delete $dir"
- }
-
- walk_files $up_dir $delete $dist_paths
- return
- }
-
foreach item [readdir $dir] {
-
set currentPath [file join $dir $item]
if {[file isdirectory $currentPath]} {
-
walk_files $currentPath $delete $dist_paths
-
} else {
-
# If the current file isn't in the known-installed-distfiles
if {[lsearch $dist_paths $currentPath] == -1} {
set found_distfile yes
- ui_msg "Found distfile: $item"
+ ui_msg "Found unused distfile: $item"
if {$delete eq "yes"} {
-
ui_debug "Deleting file: $item"
ui_msg "Removing distfile: $item"
if {[catch {file delete $currentPath} error]} {
- ui_error "something went wrong when trying to delete $currentPath"
+ ui_error "something went wrong when trying to delete $currentPath: $error"
}
-
- # If the directory is now empty, recursively call on this directory, to delete it.
- if {[is_empty_dir $dir]} {
-
- ui_debug "Current directory is empty. Walking to $dir"
- walk_files $dir $delete $dist_paths
- }
}
}
}
}
+ if {$dir ne $root_dist && $dir ne $home_dist && [llength [readdir $dir]] == 0} {
+ # If the directory is empty, and this isn't the root folder, delete
+ # it.
+ ui_msg "Found empty directory: $dir. Attempting to delete."
+
+ if {[catch {file delete -force $dir} error] } {
+ ui_error "something went wrong when trying to delete $dir: $error"
+ }
+ }
+
return $found_distfile
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140902/0e3be0df/attachment.html>
More information about the macports-changes
mailing list