improved error message

This commit is contained in:
Bjoern Schiessle 2014-06-30 16:28:40 +02:00
parent 1004836fd3
commit 618c9fd033
1 changed files with 8 additions and 7 deletions

View File

@ -228,21 +228,23 @@ class Keymanager {
} }
$result = false; $result = false;
$fileExists = $view->file_exists('/' . $userId . '/files/' . $trimmed);
if ($view->is_dir($keyPath) && !$view->file_exists('/' . $userId . '/files/' . $trimmed)) { if ($view->is_dir($keyPath) && !$fileExists) {
\OCP\Util::writeLog('files_encryption', 'deleteFileKey: delete file key: ' . $keyPath, \OCP\Util::DEBUG); \OCP\Util::writeLog('files_encryption', 'deleteFileKey: delete file key: ' . $keyPath, \OCP\Util::DEBUG);
$result = $view->unlink($keyPath); $result = $view->unlink($keyPath);
} elseif ($view->file_exists($keyPath . '.key') && !$view->file_exists('/' . $userId . '/files/' . $trimmed)) { } elseif ($view->file_exists($keyPath . '.key') && !$fileExists) {
\OCP\Util::writeLog('files_encryption', 'deleteFileKey: delete file key: ' . $keyPath, \OCP\Util::DEBUG); \OCP\Util::writeLog('files_encryption', 'deleteFileKey: delete file key: ' . $keyPath, \OCP\Util::DEBUG);
$result = $view->unlink($keyPath . '.key'); $result = $view->unlink($keyPath . '.key');
} }
if (!$result) { if ($fileExists) {
\OCP\Util::writeLog('Encryption library',
'Did not delete the file key, file still exists: ' . '/' . $userId . '/files/' . $trimmed, \OCP\Util::ERROR);
} elseif (!$result) {
\OCP\Util::writeLog('Encryption library', \OCP\Util::writeLog('Encryption library',
'Could not delete keyfile; does not exist: "' . $keyPath, \OCP\Util::ERROR); 'Could not delete keyfile; does not exist: "' . $keyPath, \OCP\Util::ERROR);
} }
return $result; return $result;
@ -508,7 +510,6 @@ class Keymanager {
$realFile = $realFileDir . self::getFilenameFromShareKey($file); $realFile = $realFileDir . self::getFilenameFromShareKey($file);
foreach ($userIds as $userId) { foreach ($userIds as $userId) {
if (preg_match("/(.*)." . $userId . ".shareKey/", $file)) { if (preg_match("/(.*)." . $userId . ".shareKey/", $file)) {
//TODO from $dir I need to strip /user/files_encryption/share-keys
if ($userId === $owner && if ($userId === $owner &&
$view->file_exists($realFile)) { $view->file_exists($realFile)) {
\OCP\Util::writeLog('files_encryption', 'original file still exists, keep owners share key!', \OCP\Util::ERROR); \OCP\Util::writeLog('files_encryption', 'original file still exists, keep owners share key!', \OCP\Util::ERROR);