Skip to content

Commit a6c692d

Browse files
committed
Improve Filemanager unzip speed
- compressing speed is not improved in this commit Relates hestiacp#925
1 parent 632b416 commit a6c692d

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace Filegator\Services\Archiver\Adapters;
4+
5+
use Filegator\Container\Container;
6+
use Filegator\Services\Archiver\ArchiverInterface;
7+
use Filegator\Services\Service;
8+
use Filegator\Services\Storage\Filesystem as Storage;
9+
use Filegator\Services\Tmpfs\TmpfsInterface;
10+
11+
12+
class HestiaZipArchiver extends ZipArchiver implements Service, ArchiverInterface
13+
{
14+
protected $container;
15+
16+
public function __construct(TmpfsInterface $tmpfs, Container $container)
17+
{
18+
$this->tmpfs = $tmpfs;
19+
$this->container = $container;
20+
}
21+
22+
public function uncompress(string $source, string $destination, Storage $storage)
23+
{
24+
25+
$auth = $this->container->get('Filegator\Services\Auth\AuthInterface');
26+
27+
$v_user = basename($auth->user()->getUsername());
28+
29+
if(!strlen($v_user)) {
30+
return;
31+
}
32+
33+
if(strpos($source, '/home') === false) {
34+
$source = "/home/$v_user/" . $source;
35+
}
36+
37+
if(strpos($destination, '/home') === false) {
38+
$destination = "/home/$v_user/" . $destination;
39+
}
40+
41+
exec ("sudo /usr/local/hestia/bin/v-extract-fs-archive " .
42+
escapeshellarg($v_user) . " " .
43+
escapeshellarg($source) . " " .
44+
escapeshellarg($destination)
45+
,$output, $return_var);
46+
47+
}
48+
}

install/deb/filemanager/filegator/configuration.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
]);
4343
};
4444

45+
$dist_config['services']['Filegator\Services\Archiver\ArchiverInterface'] = [
46+
'handler' => '\Filegator\Services\Archiver\Adapters\HestiaZipArchiver',
47+
'config' => [],
48+
];
49+
4550
$dist_config['services']['Filegator\Services\Auth\AuthInterface'] = [
4651
'handler' => '\Filegator\Services\Auth\Adapters\HestiaAuth',
4752
'config' => [

0 commit comments

Comments
 (0)