Forráskód Böngészése

bugfix disksizevalidator

andre 4 éve
szülő
commit
4d5801cf6c
1 módosított fájl, 12 hozzáadás és 3 törlés
  1. 12 3
      app/UI/VmCreate/Validators/DiskSizeValidator.php

+ 12 - 3
app/UI/VmCreate/Validators/DiskSizeValidator.php

@@ -33,15 +33,24 @@ class DiskSizeValidator extends BaseValidator
         }
         $diskResource =    $resurceManager ->disk();
         $diskResource->setTotal($diskResource->getTotal()-$additionalSize);
-        $this->maxValue = $diskResource->free();
+        if ($this->isWhmcsConfigOption(ConfigurableOption::STORAGE)) {
+            $this->maxValue = $this->getWhmcsConfigOption(ConfigurableOption::STORAGE) - $diskResource->getUsed();
+        } else {
+            $this->maxValue = $diskResource->free();
+        }
+        if ($this->maxValue > $diskResource->getMax()) {
+            $this->addValidationError('PleaseProvideANumericValueBetween', false, ['minValue' => $this->minValue, 'maxValue' => $diskResource->getMax()]);
+            return false;
+        }
+
         $this->minValue =  $diskResource->getMin();
 
         logModuleCall(
             'proxmoxCloud',
             __FUNCTION__,
-            $resurceManager->disk()->free(),
+            $resurceManager->disk()->getFree(),
             'Debug',
-            $this->getWhmcsConfigOption(ConfigurableOption::STORAGE)
+            $this->maxValue
         );
 
         if(preg_match("/\./", $data)){