fix: clear temp fies during index (fix #355)
parent
3a7037d3cd
commit
6261ffd35a
|
@ -33,6 +33,7 @@ use OCP\Files\IRootFolder;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IDBConnection;
|
use OCP\IDBConnection;
|
||||||
use OCP\IPreview;
|
use OCP\IPreview;
|
||||||
|
use OCP\ITempManager;
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
@ -68,6 +69,7 @@ class Index extends Command
|
||||||
protected IDBConnection $connection;
|
protected IDBConnection $connection;
|
||||||
protected Connection $connectionForSchema;
|
protected Connection $connectionForSchema;
|
||||||
protected TimelineWrite $timelineWrite;
|
protected TimelineWrite $timelineWrite;
|
||||||
|
protected ITempManager $tempManager;
|
||||||
|
|
||||||
// Stats
|
// Stats
|
||||||
private int $nUser = 0;
|
private int $nUser = 0;
|
||||||
|
@ -85,7 +87,8 @@ class Index extends Command
|
||||||
IPreview $preview,
|
IPreview $preview,
|
||||||
IConfig $config,
|
IConfig $config,
|
||||||
IDBConnection $connection,
|
IDBConnection $connection,
|
||||||
Connection $connectionForSchema
|
Connection $connectionForSchema,
|
||||||
|
ITempManager $tempManager
|
||||||
) {
|
) {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
|
@ -95,6 +98,7 @@ class Index extends Command
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->connection = $connection;
|
$this->connection = $connection;
|
||||||
$this->connectionForSchema = $connectionForSchema;
|
$this->connectionForSchema = $connectionForSchema;
|
||||||
|
$this->tempManager = $tempManager;
|
||||||
$this->timelineWrite = new TimelineWrite($connection);
|
$this->timelineWrite = new TimelineWrite($connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,6 +310,7 @@ class Index extends Command
|
||||||
$progress = (float) (($progress_i / $progress_n) * 100);
|
$progress = (float) (($progress_i / $progress_n) * 100);
|
||||||
$this->outputSection->overwrite(sprintf('%.2f%%', $progress).' scanning '.$node->getPath());
|
$this->outputSection->overwrite(sprintf('%.2f%%', $progress).' scanning '.$node->getPath());
|
||||||
$this->parseFile($node, $opts);
|
$this->parseFile($node, $opts);
|
||||||
|
$this->tempManager->clean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ use bantu\IniGetWrapper\IniGetWrapper;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\AppFramework\Http\JSONResponse;
|
use OCP\AppFramework\Http\JSONResponse;
|
||||||
use OCP\ISession;
|
use OCP\ISession;
|
||||||
|
use OCP\ITempManager;
|
||||||
use OCP\Security\ISecureRandom;
|
use OCP\Security\ISecureRandom;
|
||||||
|
|
||||||
class DownloadController extends ApiBase
|
class DownloadController extends ApiBase
|
||||||
|
@ -193,6 +194,9 @@ class DownloadController extends ApiBase
|
||||||
// So we need to add a number to the end of the name
|
// So we need to add a number to the end of the name
|
||||||
$nameCounts = [];
|
$nameCounts = [];
|
||||||
|
|
||||||
|
/** @var ITempManager for clearing temp files */
|
||||||
|
$tempManager = \OC::$server->get(ITempManager::class);
|
||||||
|
|
||||||
// Send each file
|
// Send each file
|
||||||
foreach ($fileIds as $fileId) {
|
foreach ($fileIds as $fileId) {
|
||||||
if (connection_aborted()) {
|
if (connection_aborted()) {
|
||||||
|
@ -265,6 +269,9 @@ class DownloadController extends ApiBase
|
||||||
if (false !== $handle) {
|
if (false !== $handle) {
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear any temp files
|
||||||
|
$tempManager->clean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue