/** * Fixes the preview cache by replacing the broken thumbnail with ours * * WARNING: Will break if the thumbnail folder ever moves or if encryption is turned on for * thumbnails * * @param resource $fixedPreview * * @return \OCP\IImage */ private function fixPreviewCache($fixedPreview) { $owner = $this->userId; $file = $this->file; $preview = $this->preview; $fixedPreviewObject = new Image($fixedPreview); // Get the location where the broken thumbnail is stored $thumbnailFolder = $this->dataDir . '/' . $owner . '/'; $thumbnail = $thumbnailFolder . $preview->isCached($file->getId()); // Caching it for next time if ($fixedPreviewObject->save($thumbnail)) { $previewData = $fixedPreviewObject; } else { $previewData = $preview->getPreview(); } return $previewData; }