Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable10] Fix checksums not being updated on modifying shared file for objectstore #32364

Merged
merged 1 commit into from
Aug 17, 2018
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
23 changes: 22 additions & 1 deletion apps/files_sharing/lib/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,31 @@ private function getSourceScanner() {
}
}

/**
* scan a folder and all it's children, use source scanner if needed
*
* @inheritdoc
*/
public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) {
$sourceScanner = $this->getSourceScanner();
if ($sourceScanner instanceof NoopScanner) {
list(, $internalPath) = $this->storage->resolvePath($path);
return $sourceScanner->scan($internalPath, $recursive, $reuse, $lock);
} else {
return parent::scan($path, $recursive, $reuse, $lock);
}
}

/**
* scan a single file and use source scanner if needed
*
* @inheritdoc
*/
public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) {
$sourceScanner = $this->getSourceScanner();
if ($sourceScanner instanceof NoopScanner) {
return [];
list(, $internalPath) = $this->storage->resolvePath($file);
return parent::scan($internalPath, $reuseExisting, $parentId, $cacheData, $lock);
} else {
return parent::scanFile($file, $reuseExisting, $parentId, $cacheData, $lock);
}
Expand Down
31 changes: 20 additions & 11 deletions lib/private/Files/ObjectStore/NoopScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function __construct(Storage $storage) {
* @return array an array of metadata of the scanned file
*/
public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) {
$this->updateChecksums($file);
return [];
}

Expand All @@ -56,17 +57,17 @@ public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData =
*/
public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) {
// we only update the checksums - still returning no data
$meta = $this->storage->getMetaData($path);
if (!empty($meta['checksum'])) {
$this->storage->getCache()->put(
$path,
['checksum' => $meta['checksum']]
);
}

$this->updateChecksums($path);
return [];
}

/**
* walk over any folders that are not fully scanned yet and scan them
*/
public function backgroundScan() {
//noop
}

/**
* scan all the files and folders in a folder
*
Expand All @@ -81,9 +82,17 @@ protected function scanChildren($path, $recursive = self::SCAN_RECURSIVE, $reuse
}

/**
* walk over any folders that are not fully scanned yet and scan them
* Update file checksums
*
* @param string $path
*/
public function backgroundScan() {
//noop
private function updateChecksums($path) {
$meta = $this->storage->getMetaData($path);
if (!empty($meta['checksum'])) {
$this->storage->getCache()->put(
$path,
['checksum' => $meta['checksum']]
);
}
}
}