Browse Source

Make sure packages move in older provider files once a month max

Jordi Boggiano 12 years ago
parent
commit
ae1fc1324a
1 changed files with 11 additions and 4 deletions
  1. 11 4
      src/Packagist/WebBundle/Package/Dumper.php

+ 11 - 4
src/Packagist/WebBundle/Package/Dumper.php

@@ -422,16 +422,23 @@ class Dumper
 
     private function getTargetListing($file)
     {
+        static $firstOfTheMonth;
+        if (!$firstOfTheMonth) {
+            $date = new \DateTime;
+            $date->setDate($date->format('Y'), $date->format('m'), 1);
+            $date->setTime(0, 0, 0);
+            $firstOfTheMonth = $date->format('U');
+        }
+
         $mtime = filemtime($file);
-        $now = time();
 
-        if ($mtime < $now - 86400 * 180) {
+        if ($mtime < $firstOfTheMonth - 86400 * 180) {
             return 'providers-archived.json';
         }
-        if ($mtime < $now - 86400 * 60) {
+        if ($mtime < $firstOfTheMonth - 86400 * 60) {
             return 'providers-stale.json';
         }
-        if ($mtime < $now - 86400 * 10) {
+        if ($mtime < $firstOfTheMonth - 86400 * 10) {
             return 'providers-active.json';
         }