Răsfoiți Sursa

apply limit snapshots per VM

andre 2 ani în urmă
părinte
comite
f53f23a372
1 a modificat fișierele cu 8 adăugiri și 11 ștergeri
  1. 8 11
      app/UI/Snapshot/Providers/SnapshotProvider.php

+ 8 - 11
app/UI/Snapshot/Providers/SnapshotProvider.php

@@ -46,20 +46,17 @@ class SnapshotProvider extends BaseDataProvider implements ClientArea
     {
 
         $this->acl()->snapshot();
-        $this->resourceGuard()->snapshotLimit();
         $vm = \ModulesGarden\ProxmoxAddon\Core\Helper\sl('Vm')->getVm();
 
-        $testRepo = new SnapshotRepository();
-        $testRepo->setApi($this->api());
-        $testRepo->findByVm($vm);
+        $snapRepo = new SnapshotRepository();
+        $snapRepo->setApi($this->api());
+        $snapRepo->findByVm($vm);
 
-        logModuleCall(
-            'ProxmoxCloudVps',
-            __FUNCTION__,
-            $this->getWhmcsConfigOption(ConfigurableOption::SNAPSHOTS, $this->configuration()->getSnapshotMaxFiles()),
-            'Debug',
-            $testRepo->count()
-        );
+        $maxSnap = $this->getWhmcsConfigOption(ConfigurableOption::SNAPSHOTS, $this->configuration()->getSnapshotMaxFiles());
+        if ($maxSnap != "-1" && $snapRepo->count() >= $maxSnap)
+        {
+            throw new \Exception(sl("lang")->tr("The maximum number of snapshots has been exceeded. Please remove the old snapshots."));
+        }
 
         $snapshot = new Snapshot();
         $snapshot->setApi($this->api());