Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions apps/files_trashbin/lib/Trashbin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use OC\Files\View;
use OC\User\NoUserException;
use OC_User;
use OCA\Files_Trashbin\AppInfo\Application;
use OCA\Files_Trashbin\Command\Expire;
use OCA\Files_Trashbin\Events\BeforeNodeRestoredEvent;
use OCA\Files_Trashbin\Events\NodeRestoredEvent;
Expand Down Expand Up @@ -844,7 +843,7 @@ public static function expire($user) {
$dirContent = Helper::getTrashFiles('/', $user, 'mtime');

// delete all files older then $retention_obligation
[$delSize, $count] = self::deleteExpiredFiles($dirContent, $user, $availableSpace <= 0);
[$delSize, $count] = self::deleteExpiredFiles($dirContent, $user);

$availableSpace += $delSize;

Expand All @@ -857,9 +856,7 @@ public static function expire($user) {
*/
private static function scheduleExpire($user) {
// let the admin disable auto expire
/** @var Application $application */
$application = Server::get(Application::class);
$expiration = $application->getContainer()->query('Expiration');
$expiration = Server::get(Expiration::class);
if ($expiration->isEnabled()) {
Server::get(IBus::class)->push(new Expire($user));
}
Expand All @@ -875,14 +872,12 @@ private static function scheduleExpire($user) {
* @return int|float size of deleted files
*/
protected static function deleteFiles(array $files, string $user, int|float $availableSpace): int|float {
/** @var Application $application */
$application = Server::get(Application::class);
$expiration = $application->getContainer()->query('Expiration');
$expiration = Server::get(Expiration::class);
$size = 0;

if ($availableSpace < 0) {
if ($availableSpace <= 0) {
foreach ($files as $file) {
if ($availableSpace < 0 && $expiration->isExpired($file['mtime'], true)) {
if ($availableSpace <= 0 && $expiration->isExpired($file['mtime'], true)) {
$tmp = self::delete($file['name'], $user, $file['mtime']);
Server::get(LoggerInterface::class)->info(
'remove "' . $file['name'] . '" (' . $tmp . 'B) to meet the limit of trash bin size (50% of available quota) for user "{user}"',
Expand All @@ -906,18 +901,16 @@ protected static function deleteFiles(array $files, string $user, int|float $ava
*
* @param array $files list of files sorted by mtime
* @param string $user
* @param bool $quotaExceeded
* @return array{int|float, int} size of deleted files and number of deleted files
*/
public static function deleteExpiredFiles($files, $user, bool $quotaExceeded = false) {
/** @var Expiration $expiration */
public static function deleteExpiredFiles($files, $user) {
$expiration = Server::get(Expiration::class);
$size = 0;
$count = 0;
foreach ($files as $file) {
$timestamp = $file['mtime'];
$filename = $file['name'];
if ($expiration->isExpired($timestamp, $quotaExceeded)) {
if ($expiration->isExpired($timestamp)) {
try {
$size += self::delete($filename, $user, $timestamp);
$count++;
Expand Down
2 changes: 0 additions & 2 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1907,8 +1907,6 @@
<code><![CDATA[getUserFolder]]></code>
<code><![CDATA[getUserFolder]]></code>
<code><![CDATA[getUserFolder]]></code>
<code><![CDATA[query]]></code>
<code><![CDATA[query]]></code>
</DeprecatedMethod>
<InternalClass>
<code><![CDATA[new View('/' . $owner)]]></code>
Expand Down
Loading