private function init() { if ($this->initialized) { return; } $this->initialized = true; Filesystem::initMountPoints($this->share['uid_owner']); $sourcePath = $this->ownerView->getPath($this->share['file_source']); list($this->sourceStorage, $sourceInternalPath) = $this->ownerView->resolvePath($sourcePath); $this->sourceRootInfo = $this->sourceStorage->getCache()->get($sourceInternalPath); }
/** * @param \OC\Files\Storage\Shared $storage * @param IStorage $sourceStorage * @param ICacheEntry $sourceRootInfo */ public function __construct($storage, IStorage $sourceStorage, ICacheEntry $sourceRootInfo) { $this->storage = $storage; $this->sourceStorage = $sourceStorage; $this->sourceRootInfo = $sourceRootInfo; $this->sourceCache = $sourceStorage->getCache(); parent::__construct($this->sourceCache, $this->sourceRootInfo->getPath()); }
public function testTimePropagation() { $paths = ['', 'foo', 'foo/bar']; $oldTime = time() - 200; $targetTime = time() - 100; $now = time(); $cache = $this->storage->getCache(); $cache->put('', ['mtime' => $now]); $cache->put('foo', ['mtime' => $now]); $cache->put('foo/bar', ['mtime' => $oldTime]); $cache->put('foo/bar/file.txt', ['mtime' => $oldTime]); $this->storage->getPropagator()->propagateChange('foo/bar/file.txt', $targetTime); $newInfos = $this->getFileInfos($paths); $this->assertEquals($targetTime, $newInfos['foo/bar']->getMTime()); // dont lower mtimes $this->assertEquals($now, $newInfos['foo']->getMTime()); $this->assertEquals($now, $newInfos['']->getMTime()); }
private function init() { if ($this->initialized) { return; } $this->initialized = true; try { Filesystem::initMountPoints($this->superShare->getShareOwner()); $sourcePath = $this->ownerView->getPath($this->superShare->getNodeId()); list($this->sourceStorage, $sourceInternalPath) = $this->ownerView->resolvePath($sourcePath); $this->sourceRootInfo = $this->sourceStorage->getCache()->get($sourceInternalPath); } catch (\Exception $e) { $this->logger->logException($e); } }
/** * Rename a file or folder in the cache and update the size, etag and mtime of the parent folders * * @param IStorage $sourceStorage * @param string $source * @param string $target */ public function renameFromStorage(IStorage $sourceStorage, $source, $target) { if (!$this->enabled or Scanner::isPartialFile($source) or Scanner::isPartialFile($target)) { return; } $time = time(); $sourceCache = $sourceStorage->getCache(); $sourceUpdater = $sourceStorage->getUpdater(); $sourcePropagator = $sourceStorage->getPropagator(); if ($sourceCache->inCache($source)) { if ($this->cache->inCache($target)) { $this->cache->remove($target); } if ($sourceStorage === $this->storage) { $this->cache->move($source, $target); } else { $this->cache->moveFromCache($sourceCache, $source, $target); } } if (pathinfo($source, PATHINFO_EXTENSION) !== pathinfo($target, PATHINFO_EXTENSION)) { // handle mime type change $mimeType = $this->storage->getMimeType($target); $fileId = $this->cache->getId($target); $this->cache->update($fileId, ['mimetype' => $mimeType]); } if ($sourceCache instanceof Cache) { $sourceCache->correctFolderSize($source); } if ($this->cache instanceof Cache) { $this->cache->correctFolderSize($target); } if ($sourceUpdater instanceof Updater) { $sourceUpdater->correctParentStorageMtime($source); } $this->correctParentStorageMtime($target); $this->updateStorageMTimeOnly($target); $sourcePropagator->propagateChange($source, $time); $this->propagator->propagateChange($target, $time); }