Esempio n. 1
0
 public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath)
 {
     return Common::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
 }
Esempio n. 2
0
 public function hasUpdated($path, $time)
 {
     if ($this->is_file($path)) {
         return parent::hasUpdated($path, $time);
     }
     $path = $this->normalizePath($path);
     $dh = $this->opendir($path);
     $content = array();
     while (($file = readdir($dh)) !== false) {
         $content[] = $file;
     }
     if ($path === '.') {
         $path = '';
     }
     $cachedContent = $this->getCache()->getFolderContents($path);
     $cachedNames = array_map(function ($content) {
         return $content['name'];
     }, $cachedContent);
     sort($cachedNames);
     sort($content);
     return $cachedNames != $content;
 }
Esempio n. 3
0
 /** {@inheritdoc} */
 public function getETag($path)
 {
     $this->init();
     $path = $this->cleanPath($path);
     $response = $this->propfind($path);
     if (isset($response['{DAV:}getetag'])) {
         return trim($response['{DAV:}getetag'], '"');
     }
     return parent::getEtag($path);
 }
Esempio n. 4
0
	/**
	 * @param \OCP\Files\Storage $sourceStorage
	 * @param string $sourceInternalPath
	 * @param string $targetInternalPath
	 * @return bool
	 */
	public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
		if ($sourceStorage->instanceOfStorage('\OC\Files\Storage\Local')) {
			/**
			 * @var \OC\Files\Storage\Local $sourceStorage
			 */
			$rootStorage = new Local(['datadir' => '/']);
			return $rootStorage->rename($sourceStorage->getSourcePath($sourceInternalPath), $this->getSourcePath($targetInternalPath));
		} else {
			return parent::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
		}
	}
Esempio n. 5
0
 /**
  * Test a storage for availability
  *
  * @return bool
  */
 public function test()
 {
     try {
         return parent::test();
     } catch (Exception $e) {
         return false;
     }
 }
Esempio n. 6
0
 public function hasUpdated($path, $time)
 {
     $appConfig = \OC::$server->getAppConfig();
     if ($this->is_file($path)) {
         return parent::hasUpdated($path, $time);
     } else {
         // Google Drive doesn't change modified times of folders when files inside are updated
         // Instead we use the Changes API to see if folders have been updated, and it's a pain
         $folder = $this->getDriveFile($path);
         if ($folder) {
             $result = false;
             $folderId = $folder->getId();
             $startChangeId = $appConfig->getValue('files_external', $this->getId() . 'cId');
             $params = array('includeDeleted' => true, 'includeSubscribed' => true);
             if (isset($startChangeId)) {
                 $startChangeId = (int) $startChangeId;
                 $largestChangeId = $startChangeId;
                 $params['startChangeId'] = $startChangeId + 1;
             } else {
                 $largestChangeId = 0;
             }
             $pageToken = true;
             while ($pageToken) {
                 if ($pageToken !== true) {
                     $params['pageToken'] = $pageToken;
                 }
                 $changes = $this->service->changes->listChanges($params);
                 if ($largestChangeId === 0 || $largestChangeId === $startChangeId) {
                     $largestChangeId = $changes->getLargestChangeId();
                 }
                 if (isset($startChangeId)) {
                     // Check if a file in this folder has been updated
                     // There is no way to filter by folder at the API level...
                     foreach ($changes->getItems() as $change) {
                         $file = $change->getFile();
                         if ($file) {
                             foreach ($file->getParents() as $parent) {
                                 if ($parent->getId() === $folderId) {
                                     $result = true;
                                     // Check if there are changes in different folders
                                 } else {
                                     if ($change->getId() <= $largestChangeId) {
                                         // Decrement id so this change is fetched when called again
                                         $largestChangeId = $change->getId();
                                         $largestChangeId--;
                                     }
                                 }
                             }
                         }
                     }
                     $pageToken = $changes->getNextPageToken();
                 } else {
                     // Assuming the initial scan just occurred and changes are negligible
                     break;
                 }
             }
             $appConfig->setValue('files_external', $this->getId() . 'cId', $largestChangeId);
             return $result;
         }
     }
     return false;
 }
Esempio n. 7
0
 public function getETag($path)
 {
     if ($path == '') {
         return parent::getETag($path);
     }
     if ($source = $this->getSourcePath($path)) {
         list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
         return $storage->getETag($internalPath);
     }
     return null;
 }
Esempio n. 8
0
 /**
  * @param string $path
  * @param string $data
  */
 public function file_put_contents($path, $data)
 {
     $path = $this->cleanPath($path);
     $result = parent::file_put_contents($path, $data);
     $this->statCache->remove($path);
     return $result;
 }