add some debug logging to check if paths are correct after moving a file to trash

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2021-03-01 22:06:56 +01:00
parent 148cc83c52
commit 2278364193
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
1 changed files with 19 additions and 0 deletions

View File

@ -54,6 +54,7 @@ use OC\Files\View;
use OCA\Files_Trashbin\AppInfo\Application;
use OCA\Files_Trashbin\Command\Expire;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\NotFoundException;
@ -346,6 +347,24 @@ class Trashbin {
return false;
}
$cache = $trashStorage->getCache();
$trashCacheItem = $cache->get($trashInternalPath);
$logger = \OC::$server->getLogger();
if ($trashCacheItem instanceof ICacheEntry) {
$parentCacheItem = $cache->get($trashCacheItem['parent']);
if ($parentCacheItem instanceof ICacheEntry) {
$parentPath = $parentCacheItem->getPath();
$expectedPath = $parentPath . '/' . $trashCacheItem->getName();
if ($expectedPath !== $trashCacheItem->getPath()) {
$logger->error("Trash item ($trashInternalPath) has a parent item with the wrong path ($parentPath) after moving to trash");
}
} else {
$logger->error("Trash item ($trashInternalPath) has no parent in cache after moving to trash");
}
} else {
$logger->error("Trash item ($trashInternalPath) not found in cache after moving to trash");
}
if ($moveSuccessful) {
$query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$query->insert('files_trash')