Skip to content
Closed
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
3 changes: 3 additions & 0 deletions apps/files/appinfo/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
*/
function owncloud_reset_encrypted_flag(\OCP\IDBConnection $conn) {
$conn->executeUpdate('UPDATE `*PREFIX*filecache` SET `encrypted` = 0 WHERE `encrypted` = 1');
if (isset(\OC\Files\Cache\Cache::$metaDataCache)) {
\OC\Files\Cache\Cache::$metaDataCache->clear();
}
}

// Current version of ownCloud before the update is 8.1.0 or 8.2.0.(0-2)
Expand Down
4 changes: 4 additions & 0 deletions apps/files/lib/Command/DeleteOrphanedFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

namespace OCA\Files\Command;

use OC\Files\Cache\Cache;
use OCP\IDBConnection;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -75,6 +76,9 @@ public function execute(InputInterface $input, OutputInterface $output) {
}
$result->closeCursor();
}
if (Cache::$metaDataCache !== null) {
Cache::$metaDataCache->clear();
}

$output->writeln("$deletedEntries orphaned file cache entries deleted");
}
Expand Down
48 changes: 28 additions & 20 deletions apps/files/tests/BackgroundJob/DeleteOrphanedItemsJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

namespace OCA\Files\Tests\BackgroundJob;

use OC\Files\Cache\Cache;
use OCA\Files\BackgroundJob\DeleteOrphanedItems;
use OCP\DB\QueryBuilder\IQueryBuilder;

Expand All @@ -42,6 +43,17 @@ protected function setup() {
$this->connection = \OC::$server->getDatabaseConnection();
}

protected function cleanup($fileId, $table){
$query = $this->connection->getQueryBuilder();
$query->delete('filecache')
->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)))
->execute();
if (Cache::$metaDataCache !== null) {
Cache::$metaDataCache->clear();
}
$this->cleanMapping($table);
}

protected function cleanMapping($table) {
$query = $this->connection->getQueryBuilder();
$query->delete($table)->execute();
Expand Down Expand Up @@ -71,6 +83,9 @@ public function testClearSystemTagMappings() {
'path' => $query->createNamedParameter('apps/files/tests/deleteorphanedtagsjobtest.php'),
'path_hash' => $query->createNamedParameter(\md5('apps/files/tests/deleteorphanedtagsjobtest.php')),
])->execute();
if (Cache::$metaDataCache !== null) {
Cache::$metaDataCache->clear();
}
$fileId = $query->getLastInsertId();

// Existing file
Expand Down Expand Up @@ -100,11 +115,7 @@ public function testClearSystemTagMappings() {
$mapping = $this->getMappings('systemtag_object_mapping');
$this->assertCount(1, $mapping);

$query = $this->connection->getQueryBuilder();
$query->delete('filecache')
->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)))
->execute();
$this->cleanMapping('systemtag_object_mapping');
$this->cleanup($fileId, 'systemtag_object_mapping');
}

/**
Expand All @@ -120,6 +131,9 @@ public function testClearUserTagMappings() {
'path' => $query->createNamedParameter('apps/files/tests/deleteorphanedtagsjobtest.php'),
'path_hash' => $query->createNamedParameter(\md5('apps/files/tests/deleteorphanedtagsjobtest.php')),
])->execute();
if (Cache::$metaDataCache !== null) {
Cache::$metaDataCache->clear();
}
$fileId = $query->getLastInsertId();

// Existing file
Expand Down Expand Up @@ -149,11 +163,7 @@ public function testClearUserTagMappings() {
$mapping = $this->getMappings('vcategory_to_object');
$this->assertCount(1, $mapping);

$query = $this->connection->getQueryBuilder();
$query->delete('filecache')
->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)))
->execute();
$this->cleanMapping('vcategory_to_object');
$this->cleanup($fileId, 'vcategory_to_object');
}

/**
Expand All @@ -169,6 +179,9 @@ public function testClearComments() {
'path' => $query->createNamedParameter('apps/files/tests/deleteorphanedtagsjobtest.php'),
'path_hash' => $query->createNamedParameter(\md5('apps/files/tests/deleteorphanedtagsjobtest.php')),
])->execute();
if (Cache::$metaDataCache !== null) {
Cache::$metaDataCache->clear();
}
$fileId = $query->getLastInsertId();

// Existing file
Expand Down Expand Up @@ -200,11 +213,7 @@ public function testClearComments() {
$mapping = $this->getMappings('comments');
$this->assertCount(1, $mapping);

$query = $this->connection->getQueryBuilder();
$query->delete('filecache')
->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)))
->execute();
$this->cleanMapping('comments');
$this->cleanup($fileId, 'comments');
}

/**
Expand All @@ -220,6 +229,9 @@ public function testClearCommentReadMarks() {
'path' => $query->createNamedParameter('apps/files/tests/deleteorphanedtagsjobtest.php'),
'path_hash' => $query->createNamedParameter(\md5('apps/files/tests/deleteorphanedtagsjobtest.php')),
])->execute();
if (Cache::$metaDataCache !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clear metadata cache before executing the query.

Cache::$metaDataCache->clear();
}
$fileId = $query->getLastInsertId();

// Existing file
Expand Down Expand Up @@ -249,11 +261,7 @@ public function testClearCommentReadMarks() {
$mapping = $this->getMappings('comments_read_markers');
$this->assertCount(1, $mapping);

$query = $this->connection->getQueryBuilder();
$query->delete('filecache')
->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)))
->execute();
$this->cleanMapping('comments_read_markers');
$this->cleanup($fileId, 'comments_read_markers');
}

}
4 changes: 4 additions & 0 deletions apps/files_sharing/lib/Command/CleanupRemoteStorages.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

namespace OCA\Files_Sharing\Command;

use OC\Files\Cache\Cache;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use Symfony\Component\Console\Command\Command;
Expand Down Expand Up @@ -129,6 +130,9 @@ public function deleteFiles ($numericId, OutputInterface $output) {
);
$output->write("deleting files for storage $numericId ... ");
$count = $queryBuilder->execute();
if (Cache::$metaDataCache !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clear before executing the query

Cache::$metaDataCache->clear();
}
$output->writeln("deleted $count");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

namespace OCA\Files_Sharing\Tests\Command;

use OC\Files\Cache\Cache;
use OCA\Files_Sharing\Command\CleanupRemoteStorages;
use Test\TestCase;

Expand Down Expand Up @@ -101,6 +102,9 @@ protected function setup() {
$filesQuery->setParameter(2, \md5('file' . $i));
$filesQuery->execute();
}
if (Cache::$metaDataCache !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same (clear)

Cache::$metaDataCache->clear();
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions apps/testing/lib/BigFileID.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

namespace OCA\Testing;

use OC\Files\Cache\Cache;
use OCP\IDBConnection;

/**
Expand Down Expand Up @@ -53,6 +54,9 @@ public function increaseFileIDsBeyondMax32bits(){
'', '4', '3', '163', '1499256550', '1499256550',
'0', '0', '595cd6e63f375', '27', 'NULL')";
$this->connection->executeQuery($query);
if (Cache::$metaDataCache !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same (clear)

Cache::$metaDataCache->clear();
}
}
return new \OC_OCS_Result();
}
Expand Down
Loading