浏览代码

Keep track of ~dev file dumps independently as they can be dumped at different times and especially only those can be dumped

Jordi Boggiano 5 年之前
父节点
当前提交
37af48f506

+ 3 - 1
src/Packagist/WebBundle/Controller/PackageController.php

@@ -136,8 +136,10 @@ class PackageController extends Controller
             // if a package is dumped then deleted then dumped again because it gets re-added, we want to keep the update action
             // but if it is deleted and marked as dumped within 10 seconds of the deletion, it probably was a race condition between
             // dumped job and deletion, so let's replace it by a delete job anyway
-            if (!isset($actions[$package]) || $actions[$package]['time'] < $time - (10 * 10000)) {
+            $newestUpdate = max($actions[$package]['time'] ?? 0, $actions[$package.'~dev']['time'] ?? 0);
+            if ($newestUpdate < $time + (10 * 10000)) {
                 $actions[$package] = ['type' => 'delete', 'package' => $package, 'time' => floor($time / 10000)];
+                unset($actions[$package.'~dev']);
             }
         }
 

+ 2 - 1
src/Packagist/WebBundle/Package/SymlinkDumper.php

@@ -869,9 +869,10 @@ class SymlinkDumper
         file_put_contents($path.'.tmp', $contents);
         rename($path.'.tmp', $path);
 
-        if (!preg_match('{/([^/]+/[^/]+?)(~dev)?\.json$}', $path, $match)) {
+        if (!preg_match('{/([^/]+/[^/]+?(~dev)?)\.json$}', $path, $match)) {
             throw new \LogicException('Could not match package name from '.$path);
         }
+
         $this->redis->zadd('metadata-dumps', $timestamp, $match[1]);
     }