verify that cache entry is valid

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2021-03-12 17:23:02 +01:00
parent c2fc3195dd
commit d7748e2b4d
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
1 changed files with 3 additions and 0 deletions

View File

@ -1086,6 +1086,9 @@ class Cache implements ICache {
* @return int fileid of copied entry
*/
public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int {
if ($sourceEntry->getId() < 0) {
throw new \RuntimeException("Invalid source cache entry on copyFromCache");
}
$data = $this->cacheEntryToArray($sourceEntry);
$fileId = $this->put($targetPath, $data);
if ($fileId <= 0) {