Ejemplo n.º 1
0
	/**
	 * Update the cache for $path
	 *
	 * @param string $path
	 * @param int $time
	 */
	public function update($path, $time = null) {
		if (Scanner::isPartialFile($path)) {
			return;
		}
		/**
		 * @var \OC\Files\Storage\Storage $storage
		 * @var string $internalPath
		 */
		list($storage, $internalPath) = $this->view->resolvePath($path);
		if ($storage) {
			$this->propagator->addChange($path);
			$cache = $storage->getCache($internalPath);
			$scanner = $storage->getScanner($internalPath);
			$data = $scanner->scan($internalPath, Scanner::SCAN_SHALLOW);
			$this->correctParentStorageMtime($storage, $internalPath);
			$cache->correctFolderSize($internalPath, $data);
			$this->propagator->propagateChanges($time);
		}
	}
Ejemplo n.º 2
0
 /**
  * @param string $source
  * @param string $target
  */
 public function rename($source, $target)
 {
     if (Scanner::isPartialFile($source) or Scanner::isPartialFile($target)) {
         return;
     }
     /**
      * @var \OC\Files\Storage\Storage $sourceStorage
      * @var \OC\Files\Storage\Storage $targetStorage
      * @var string $sourceInternalPath
      * @var string $targetInternalPath
      */
     list($sourceStorage, $sourceInternalPath) = $this->view->resolvePath($source);
     // if it's a moved mountpoint we dont need to do anything
     if ($sourceInternalPath === '') {
         return;
     }
     list($targetStorage, $targetInternalPath) = $this->view->resolvePath($target);
     if ($sourceStorage && $targetStorage) {
         if ($sourceStorage === $targetStorage) {
             $cache = $sourceStorage->getCache($sourceInternalPath);
             $cache->move($sourceInternalPath, $targetInternalPath);
             if (pathinfo($sourceInternalPath, PATHINFO_EXTENSION) !== pathinfo($targetInternalPath, PATHINFO_EXTENSION)) {
                 // handle mime type change
                 $mimeType = $sourceStorage->getMimeType($targetInternalPath);
                 $fileId = $cache->getId($targetInternalPath);
                 $cache->update($fileId, array('mimetype' => $mimeType));
             }
             $cache->correctFolderSize($sourceInternalPath);
             $cache->correctFolderSize($targetInternalPath);
             $this->correctParentStorageMtime($sourceStorage, $sourceInternalPath);
             $this->correctParentStorageMtime($targetStorage, $targetInternalPath);
             $this->propagator->addChange($source);
             $this->propagator->addChange($target);
         } else {
             $this->remove($source);
             $this->update($target);
         }
         $this->propagator->propagateChanges();
     }
 }
Ejemplo n.º 3
0
 /**
  * Rename a file or folder in the cache and update the size, etag and mtime of the parent folders
  *
  * @param \OC\Files\Storage\Storage $sourceStorage
  * @param string $source
  * @param string $target
  */
 public function renameFromStorage(\OC\Files\Storage\Storage $sourceStorage, $source, $target)
 {
     if (!$this->enabled or Scanner::isPartialFile($source) or Scanner::isPartialFile($target)) {
         return;
     }
     $time = time();
     $sourceCache = $sourceStorage->getCache($source);
     $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]);
     }
     $sourceCache->correctFolderSize($source);
     $this->cache->correctFolderSize($target);
     $sourceUpdater->correctParentStorageMtime($source);
     $this->correctParentStorageMtime($target);
     $this->updateStorageMTimeOnly($target);
     $sourcePropagator->propagateChange($source, $time);
     $this->propagator->propagateChange($target, $time);
 }