Esempio n. 1
0
 /**
  * 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]);
     }
     $sourceCache->correctFolderSize($source);
     $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);
 }
Esempio n. 2
0
 /**
  * get all the metadata of a file or folder
  * *
  *
  * @param string $path
  * @return array with metadata of the file
  */
 public function getData($path)
 {
     if (!$this->storage->isReadable($path)) {
         //cant read, nothing we can do
         \OCP\Util::writeLog('OC\\Files\\Cache\\Scanner', "!!! Path '{$path}' is not readable !!!", \OCP\Util::DEBUG);
         return null;
     }
     $data = array();
     $data['mimetype'] = $this->storage->getMimeType($path);
     $data['mtime'] = $this->storage->filemtime($path);
     if ($data['mimetype'] == 'httpd/unix-directory') {
         $data['size'] = -1;
         //unknown
     } else {
         $data['size'] = $this->storage->filesize($path);
     }
     $data['etag'] = $this->storage->getETag($path);
     $data['storage_mtime'] = $data['mtime'];
     return $data;
 }
Esempio n. 3
0
 /**
  * get all the metadata of a file or folder
  * *
  *
  * @param string $path
  * @return array an array of metadata of the file
  */
 public function getData($path)
 {
     $permissions = $this->storage->getPermissions($path);
     if (!$permissions & \OCP\PERMISSION_READ) {
         //cant read, nothing we can do
         \OCP\Util::writeLog('OC\\Files\\Cache\\Scanner', "!!! Path '{$path}' is not accessible or present !!!", \OCP\Util::DEBUG);
         return null;
     }
     $data = array();
     $data['mimetype'] = $this->storage->getMimeType($path);
     $data['mtime'] = $this->storage->filemtime($path);
     if ($data['mimetype'] == 'httpd/unix-directory') {
         $data['size'] = -1;
         //unknown
     } else {
         $data['size'] = $this->storage->filesize($path);
     }
     $data['etag'] = $this->storage->getETag($path);
     $data['storage_mtime'] = $data['mtime'];
     $data['permissions'] = $permissions;
     return $data;
 }
Esempio n. 4
0
 /**
  * get the mimetype for a file or folder
  * The mimetype for a folder is required to be "httpd/unix-directory"
  *
  * @param string $path
  * @return string
  */
 public function getMimeType($path)
 {
     return $this->storage->getMimeType($path);
 }