[121228] branches/gsoc14-cleanup/src/macports1.0

ksammons at macports.org ksammons at macports.org
Fri Jun 20 16:14:11 PDT 2014


Revision: 121228
          https://trac.macports.org/changeset/121228
Author:   ksammons at macports.org
Date:     2014-06-20 16:14:11 -0700 (Fri, 20 Jun 2014)
Log Message:
-----------
Added the ability to periodically warn (annoy) the user if they haven't run reclaim in two weeks.

Modified Paths:
--------------
    branches/gsoc14-cleanup/src/macports1.0/macports.tcl
    branches/gsoc14-cleanup/src/macports1.0/reclaim.tcl

Modified: branches/gsoc14-cleanup/src/macports1.0/macports.tcl
===================================================================
--- branches/gsoc14-cleanup/src/macports1.0/macports.tcl	2014-06-20 23:14:10 UTC (rev 121227)
+++ branches/gsoc14-cleanup/src/macports1.0/macports.tcl	2014-06-20 23:14:11 UTC (rev 121228)
@@ -1191,6 +1191,9 @@
         }
     }
 
+    # Check the last time 'reclaim' was run. 
+    check_last_reclaim 
+
     # init registry
     set db_path [file join ${registry.path} registry registry.db]
     set db_exists [file exists $db_path]
@@ -4366,11 +4369,40 @@
 }
 
 proc macports::doctor_main {} {
+    
+    # Calls the main function for the 'port doctor' command.
+    #
+    # Args: 
+    #           None
+    # Returns:
+    #           0 on successful execution.
+
     doctor::main
     return 0
 }
 
+proc macports::check_last_reclaim {} {
+
+    # An abstraction layer for the reclaim function, 'check_last_run'.
+    #
+    # Args:
+    #           None
+    # Returns:
+    #           None
+
+    reclaim::check_last_run
+    return 0
+}
+
 proc macports::reclaim_main {} {
+
+    # Calls the main function for the 'port reclaim' command.
+    #
+    # Args:
+    #           None
+    # Returns:
+    #           None
+
     reclaim::main
     return 0
 }

Modified: branches/gsoc14-cleanup/src/macports1.0/reclaim.tcl
===================================================================
--- branches/gsoc14-cleanup/src/macports1.0/reclaim.tcl	2014-06-20 23:14:10 UTC (rev 121227)
+++ branches/gsoc14-cleanup/src/macports1.0/reclaim.tcl	2014-06-20 23:14:11 UTC (rev 121228)
@@ -30,6 +30,7 @@
 
         uninstall_inactive
         remove_distfiles
+        update_last_run
     }
 
     proc is_empty_dir {dir} {
@@ -65,7 +66,7 @@
             # Get the directory above the current one
             set up_dir [file dirname $dir]
 
-            puts "Found empty directory: $dir. Attempting to delete."
+            ui_msg "Found empty directory: $dir. Attempting to delete."
             file delete -force $dir
 
             walk_files $up_dir $delete $dist_paths
@@ -185,13 +186,53 @@
         #
         # Args:
         #           None
-        #Returns:
+        # Returns:
         #           A multidimensional list where each app is a sublist, i.e., [{First Application Info} {Second Application Info} {...}]
         #           Indexes of each sublist are: 0 = name, 1 = version, 2 = revision, 3 = variants, 4 = activity, and 5 = epoch.
         
         return [registry::installed] 
     }
 
+    proc update_last_run {} {
+        
+        # Updates the last_reclaim textfile with the newest time the code has been ran. 
+        #
+        # Args:
+        #           None
+        # Returns:
+        #           None
+
+        set path    [file join ${macports::portdbpath} last_reclaim.txt]
+        set fd      [open $path w]
+        puts $fd    [clock seconds]
+        close $fd
+    }
+
+    proc check_last_run {} {
+
+        # Periodically warn's the user that they haven't run 'port reclaim' in two weeks, and that they should consider doing so.
+        # 
+        # Args:
+        #           None
+        # Returns: 
+        #           None
+
+        set path    [file join ${macports::portdbpath} last_reclaim.txt]
+
+        if {[file exists $path]} {
+
+            set fd      [open $path r]
+            set time    [gets $fd]
+            close $fd
+
+            if {$time ne ""} {
+                if {[clock seconds] - $time > 1209600} {
+                    ui_warn "you haven't run 'port reclaim' in two weeks. It's recommended you run this once every two weeks to help save space on your computer."
+                }
+            }
+        }
+    }
+
     proc uninstall_inactive {} {
 
         # Attempts to uninstall all inactive applications. (Performance is now O(N)!)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140620/8f1fdde3/attachment-0001.html>


More information about the macports-changes mailing list