debug patch for checksum states
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
7f5e9ff7fc
commit
c8e90ebda5
|
@ -64,6 +64,7 @@ use OCP\ILogger;
|
||||||
use OCP\Lock\ILockingProvider;
|
use OCP\Lock\ILockingProvider;
|
||||||
use OCP\Lock\LockedException;
|
use OCP\Lock\LockedException;
|
||||||
use OCP\Share\IManager;
|
use OCP\Share\IManager;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
use Sabre\DAV\Exception;
|
use Sabre\DAV\Exception;
|
||||||
use Sabre\DAV\Exception\BadRequest;
|
use Sabre\DAV\Exception\BadRequest;
|
||||||
use Sabre\DAV\Exception\Forbidden;
|
use Sabre\DAV\Exception\Forbidden;
|
||||||
|
@ -342,13 +343,29 @@ class File extends Node implements IFile {
|
||||||
|
|
||||||
$this->refreshInfo();
|
$this->refreshInfo();
|
||||||
|
|
||||||
|
/** @var LoggerInterface $logger */
|
||||||
|
$logger = \OC::$server->get(LoggerInterface::class);
|
||||||
if (isset($this->request->server['HTTP_OC_CHECKSUM'])) {
|
if (isset($this->request->server['HTTP_OC_CHECKSUM'])) {
|
||||||
$checksum = trim($this->request->server['HTTP_OC_CHECKSUM']);
|
$checksum = trim($this->request->server['HTTP_OC_CHECKSUM']);
|
||||||
|
$logger->debug('Received checksum in header: "{checksum}", path {target}', [
|
||||||
|
'app' => 'debug_checksum',
|
||||||
|
'checksum' => $checksum,
|
||||||
|
'target' => $this->path,
|
||||||
|
]);
|
||||||
$this->fileView->putFileInfo($this->path, ['checksum' => $checksum]);
|
$this->fileView->putFileInfo($this->path, ['checksum' => $checksum]);
|
||||||
$this->refreshInfo();
|
$this->refreshInfo();
|
||||||
} elseif ($this->getChecksum() !== null && $this->getChecksum() !== '') {
|
} elseif ($this->getChecksum() !== null && $this->getChecksum() !== '') {
|
||||||
|
$logger->debug('No checksum received in header, resetting existing value, path {target}', [
|
||||||
|
'app' => 'debug_checksum',
|
||||||
|
'target' => $this->path,
|
||||||
|
]);
|
||||||
$this->fileView->putFileInfo($this->path, ['checksum' => '']);
|
$this->fileView->putFileInfo($this->path, ['checksum' => '']);
|
||||||
$this->refreshInfo();
|
$this->refreshInfo();
|
||||||
|
} else {
|
||||||
|
$logger->debug('No checksum received in header, none was set either. path {target}', [
|
||||||
|
'app' => 'debug_checksum',
|
||||||
|
'target' => $this->path,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
} catch (StorageNotAvailableException $e) {
|
} catch (StorageNotAvailableException $e) {
|
||||||
throw new ServiceUnavailable("Failed to check file size: " . $e->getMessage(), 0, $e);
|
throw new ServiceUnavailable("Failed to check file size: " . $e->getMessage(), 0, $e);
|
||||||
|
@ -606,11 +623,27 @@ class File extends Node implements IFile {
|
||||||
// FIXME: should call refreshInfo but can't because $this->path is not the of the final file
|
// FIXME: should call refreshInfo but can't because $this->path is not the of the final file
|
||||||
$info = $this->fileView->getFileInfo($targetPath);
|
$info = $this->fileView->getFileInfo($targetPath);
|
||||||
|
|
||||||
|
/** @var LoggerInterface $logger */
|
||||||
|
$logger = \OC::$server->get(LoggerInterface::class);
|
||||||
if (isset($this->request->server['HTTP_OC_CHECKSUM'])) {
|
if (isset($this->request->server['HTTP_OC_CHECKSUM'])) {
|
||||||
$checksum = trim($this->request->server['HTTP_OC_CHECKSUM']);
|
$checksum = trim($this->request->server['HTTP_OC_CHECKSUM']);
|
||||||
|
$logger->debug('(Chunk) Received checksum in header: "{checksum}", path {target}', [
|
||||||
|
'app' => 'debug_checksum',
|
||||||
|
'checksum' => $checksum,
|
||||||
|
'target' => $targetPath,
|
||||||
|
]);
|
||||||
$this->fileView->putFileInfo($targetPath, ['checksum' => $checksum]);
|
$this->fileView->putFileInfo($targetPath, ['checksum' => $checksum]);
|
||||||
} elseif ($info->getChecksum() !== null && $info->getChecksum() !== '') {
|
} elseif ($info->getChecksum() !== null && $info->getChecksum() !== '') {
|
||||||
|
$logger->debug('(Chunk) No checksum received in header, resetting existing value, path {target}', [
|
||||||
|
'app' => 'debug_checksum',
|
||||||
|
'target' => $targetPath,
|
||||||
|
]);
|
||||||
$this->fileView->putFileInfo($this->path, ['checksum' => '']);
|
$this->fileView->putFileInfo($this->path, ['checksum' => '']);
|
||||||
|
} else {
|
||||||
|
$logger->debug('(Chunk) No checksum received in header, none was set either. path {target}', [
|
||||||
|
'app' => 'debug_checksum',
|
||||||
|
'target' => $targetPath,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->fileView->unlockFile($targetPath, ILockingProvider::LOCK_SHARED);
|
$this->fileView->unlockFile($targetPath, ILockingProvider::LOCK_SHARED);
|
||||||
|
|
|
@ -41,6 +41,7 @@ use OCP\Files\StorageNotAvailableException;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IPreview;
|
use OCP\IPreview;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
use Sabre\DAV\Exception\Forbidden;
|
use Sabre\DAV\Exception\Forbidden;
|
||||||
use Sabre\DAV\Exception\NotFound;
|
use Sabre\DAV\Exception\NotFound;
|
||||||
use Sabre\DAV\IFile;
|
use Sabre\DAV\IFile;
|
||||||
|
@ -277,8 +278,20 @@ class FilesPlugin extends ServerPlugin {
|
||||||
if ($node instanceof \OCA\DAV\Connector\Sabre\File) {
|
if ($node instanceof \OCA\DAV\Connector\Sabre\File) {
|
||||||
//Add OC-Checksum header
|
//Add OC-Checksum header
|
||||||
$checksum = $node->getChecksum();
|
$checksum = $node->getChecksum();
|
||||||
|
/** @var LoggerInterface $logger */
|
||||||
|
$logger = \OC::$server->get(LoggerInterface::class);
|
||||||
if ($checksum !== null && $checksum !== '') {
|
if ($checksum !== null && $checksum !== '') {
|
||||||
|
$logger->debug('Sending checksum response: "{checksum}" for path {path}', [
|
||||||
|
'app' => 'debug_checksum',
|
||||||
|
'checksum' => $checksum,
|
||||||
|
'path' => $node->getPath(),
|
||||||
|
]);
|
||||||
$response->addHeader('OC-Checksum', $checksum);
|
$response->addHeader('OC-Checksum', $checksum);
|
||||||
|
} else {
|
||||||
|
$logger->debug('Sending no checksum header, as no value is set for path {path}', [
|
||||||
|
'app' => 'debug_checksum',
|
||||||
|
'path' => $node->getPath(),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ use OCP\Files\IMimeTypeLoader;
|
||||||
use OCP\Files\Search\ISearchQuery;
|
use OCP\Files\Search\ISearchQuery;
|
||||||
use OCP\Files\Storage\IStorage;
|
use OCP\Files\Storage\IStorage;
|
||||||
use OCP\IDBConnection;
|
use OCP\IDBConnection;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metadata cache for a storage
|
* Metadata cache for a storage
|
||||||
|
@ -286,6 +287,16 @@ class Cache implements ICache {
|
||||||
[$values, $extensionValues] = $this->normalizeData($data);
|
[$values, $extensionValues] = $this->normalizeData($data);
|
||||||
$values['storage'] = $this->getNumericStorageId();
|
$values['storage'] = $this->getNumericStorageId();
|
||||||
|
|
||||||
|
if (isset($values['checksum'])) {
|
||||||
|
/** @var LoggerInterface $logger */
|
||||||
|
$logger = \OC::$server->get(LoggerInterface::class);
|
||||||
|
$logger->debug('Inserting checksum to: "{checksum}" for path {path}', [
|
||||||
|
'app' => 'debug_checksum',
|
||||||
|
'checksum' => $values['checksum'],
|
||||||
|
'path' => $values['path'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$builder = $this->connection->getQueryBuilder();
|
$builder = $this->connection->getQueryBuilder();
|
||||||
$builder->insert('filecache');
|
$builder->insert('filecache');
|
||||||
|
@ -347,6 +358,16 @@ class Cache implements ICache {
|
||||||
|
|
||||||
[$values, $extensionValues] = $this->normalizeData($data);
|
[$values, $extensionValues] = $this->normalizeData($data);
|
||||||
|
|
||||||
|
if (isset($values['checksum'])) {
|
||||||
|
/** @var LoggerInterface $logger */
|
||||||
|
$logger = \OC::$server->get(LoggerInterface::class);
|
||||||
|
$logger->debug('Updating stored checksum to: "{checksum}" for path {file}', [
|
||||||
|
'app' => 'debug_checksum',
|
||||||
|
'checksum' => $values['checksum'],
|
||||||
|
'file' => $values['path'] ?? $this->getPathById($id),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if (count($values)) {
|
if (count($values)) {
|
||||||
$query = $this->getQueryBuilder();
|
$query = $this->getQueryBuilder();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue