Skip to content

Commit 1e114c4

Browse files
authored
Use blocking filesystem driver during VaaS file upload (#273)
The asynchronous amphp file library may in certain setups spawn multiple processes to avoid blocking file I/O. This is unsupported in some hosting environments. Starting with VaaS SDK 11.1.0 we can provide a custom amphp driver for file I/O during upload (to override the default amphp driver selection). Forcefully select the blocking implementation, which never uses multiple processes.
1 parent 0ad7cb1 commit 1e114c4

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010
],
1111
"require": {
12-
"gdata/vaas": "11.0.1",
12+
"gdata/vaas": "11.1.0",
1313
"coduo/php-humanizer": "5.0.0"
1414
},
1515
"require-dev": {

lib/Service/VerdictService.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
namespace OCA\GDataVaas\Service;
88

9-
use Exception;
9+
use Amp\File\Driver\BlockingFilesystemDriver;
10+
use Amp\File\FilesystemDriver;
1011
use OC\User\NoUserException;
1112
use OCA\GDataVaas\AppInfo\Application;
1213
use OCP\Files\EntityTooLargeException;
@@ -19,6 +20,7 @@
1920
use VaasSdk\Exceptions\VaasAuthenticationException;
2021
use VaasSdk\Exceptions\VaasClientException;
2122
use VaasSdk\Exceptions\VaasServerException;
23+
use VaasSdk\Options\ForFileOptions;
2224
use VaasSdk\Options\VaasOptions;
2325
use VaasSdk\Vaas;
2426
use VaasSdk\VaasVerdict;
@@ -35,6 +37,7 @@ class VerdictService {
3537
private FileService $fileService;
3638
private TagService $tagService;
3739
private ?Vaas $vaas = null;
40+
private FilesystemDriver $filesystemDriver;
3841
private LoggerInterface $logger;
3942

4043
public function __construct(
@@ -47,6 +50,7 @@ public function __construct(
4750
$this->appConfig = $appConfig;
4851
$this->fileService = $fileService;
4952
$this->tagService = $tagService;
53+
$this->filesystemDriver = new BlockingFilesystemDriver();
5054

5155
$this->authMethod = $this->appConfig->getValueString(
5256
Application::APP_ID, 'authMethod', 'ClientCredentials'
@@ -186,7 +190,8 @@ public function scan(string $filePath): VaasVerdict {
186190
$this->vaas = $this->createAndConnectVaas();
187191
}
188192

189-
return $this->vaas->forFileAsync($filePath)->await();
193+
$options = new ForFileOptions(true, true, ForFileOptions::DEFAULT_TIMEOUT, $this->filesystemDriver);
194+
return $this->vaas->forFileAsync($filePath, $options)->await();
190195
}
191196

192197
/**

0 commit comments

Comments
 (0)