Просмотр исходного кода

Improve Filemanager unzip speed

- compressing speed is not improved in this commit

Relates #925
Robert Zollner 5 лет назад
Родитель
Сommit
a6c692d3cc

+ 48 - 0
install/deb/filemanager/filegator/backend/Services/Archiver/Adapters/HestiaZipArchiver.php

@@ -0,0 +1,48 @@
+<?php
+
+namespace Filegator\Services\Archiver\Adapters;
+
+use Filegator\Container\Container;
+use Filegator\Services\Archiver\ArchiverInterface;
+use Filegator\Services\Service;
+use Filegator\Services\Storage\Filesystem as Storage;
+use Filegator\Services\Tmpfs\TmpfsInterface;
+
+
+class HestiaZipArchiver extends ZipArchiver implements Service, ArchiverInterface
+{
+    protected $container;
+
+    public function __construct(TmpfsInterface $tmpfs, Container $container)
+    {
+        $this->tmpfs = $tmpfs;
+        $this->container = $container;
+    }
+
+    public function uncompress(string $source, string $destination, Storage $storage)
+    {
+
+        $auth = $this->container->get('Filegator\Services\Auth\AuthInterface');
+
+        $v_user = basename($auth->user()->getUsername());
+        
+        if(!strlen($v_user)) {
+            return;
+        }
+
+        if(strpos($source, '/home') === false) {
+            $source = "/home/$v_user/" . $source;
+        }
+
+        if(strpos($destination, '/home') === false) {
+            $destination = "/home/$v_user/" . $destination;
+        }
+
+        exec ("sudo /usr/local/hestia/bin/v-extract-fs-archive " .
+            escapeshellarg($v_user)  . " " .
+            escapeshellarg($source) . " " .
+            escapeshellarg($destination)
+        ,$output, $return_var);
+
+    }
+}

+ 5 - 0
install/deb/filemanager/filegator/configuration.php

@@ -42,6 +42,11 @@ $dist_config['services']['Filegator\Services\Storage\Filesystem']['config']['ada
         ]);
     };
 
+$dist_config['services']['Filegator\Services\Archiver\ArchiverInterface'] = [
+    'handler' => '\Filegator\Services\Archiver\Adapters\HestiaZipArchiver',
+    'config' => [],
+];
+
 $dist_config['services']['Filegator\Services\Auth\AuthInterface'] = [
         'handler' => '\Filegator\Services\Auth\Adapters\HestiaAuth',
         'config' => [