Пример #1
0
 /**
  * @param integer $limit
  */
 protected function getLimitedStorage($limit)
 {
     $storage = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir));
     $storage->mkdir('files');
     $storage->getScanner()->scan('');
     return new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => $limit));
 }
Пример #2
0
 /**
  * Tests that the home storage is used in legacy mode
  * for the user's mount point
  */
 public function testLegacyHomeMount()
 {
     if (getenv('RUN_OBJECTSTORE_TESTS')) {
         $this->markTestSkipped('legacy storage unrelated to objectstore environments');
     }
     $datadir = \OC::$server->getConfig()->getSystemValue("datadirectory", \OC::$SERVERROOT . "/data");
     $userId = $this->getUniqueID('user_');
     // insert storage into DB by constructing it
     // to make initMountsPoint find its existence
     $localStorage = new \OC\Files\Storage\Local(array('datadir' => $datadir . '/' . $userId . '/'));
     // this will trigger the insert
     $cache = $localStorage->getCache();
     \OC::$server->getUserManager()->createUser($userId, $userId);
     \OC\Files\Filesystem::initMountPoints($userId);
     $homeMount = \OC\Files\Filesystem::getStorage('/' . $userId . '/');
     $this->assertTrue($homeMount->instanceOfStorage('\\OC\\Files\\Storage\\Home'));
     $this->assertEquals('local::' . $datadir . '/' . $userId . '/', $homeMount->getId());
     $user = \OC::$server->getUserManager()->get($userId);
     if ($user !== null) {
         $user->delete();
     }
     // delete storage entry
     $cache->clear();
 }
Пример #3
0
 /**
  * Tests that the home storage is used in legacy mode
  * for the user's mount point
  */
 public function testLegacyHomeMount()
 {
     $datadir = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data");
     $userId = $this->getUniqueID('user_');
     // insert storage into DB by constructing it
     // to make initMountsPoint find its existence
     $localStorage = new \OC\Files\Storage\Local(array('datadir' => $datadir . '/' . $userId . '/'));
     // this will trigger the insert
     $cache = $localStorage->getCache();
     \OC_User::createUser($userId, $userId);
     \OC\Files\Filesystem::initMountPoints($userId);
     $homeMount = \OC\Files\Filesystem::getStorage('/' . $userId . '/');
     $this->assertTrue($homeMount->instanceOfStorage('\\OC\\Files\\Storage\\Home'));
     $this->assertEquals('local::' . $datadir . '/' . $userId . '/', $homeMount->getId());
     \OC_User::deleteUser($userId);
     // delete storage entry
     $cache->clear();
 }
Пример #4
0
 private function saveFile($contents, $datadir, $author, $localpath, $filename)
 {
     $fullPath = $datadir . "/" . $author . "/" . $localpath;
     $jpgBase64 = base64_encode($contents);
     $storage = new \OC\Files\Storage\Local(["datadir" => $fullPath]);
     $result = $storage->file_put_contents($filename, base64_decode($jpgBase64));
     return ['storage' => $result, 'uploadpath' => $fullPath, 'path' => $localpath, 'filename' => $filename, 'uid' => $author];
 }
Пример #5
0
 private function uploadFile($file)
 {
     $fullPath = $this->datadir . "/" . $this->fileAuthor . "/" . $this->localpath;
     $jpgBase64 = base64_encode(file_get_contents($this->dir . '/' . $file['filename']));
     $storage = new \OC\Files\Storage\Local(["datadir" => $fullPath]);
     $result = $storage->file_put_contents($file['filename'], base64_decode($jpgBase64));
     return ['storage' => $result, 'uploadpath' => $fullPath, 'path' => $this->localpath, 'filename' => $file['filename'], 'uid' => $this->fileAuthor];
 }
Пример #6
0
 public function testDisallowSymlinksInsideDatadir()
 {
     $subDir1 = $this->tmpDir . 'sub1';
     $subDir2 = $this->tmpDir . 'sub1/sub2';
     $sym = $this->tmpDir . 'sub1/sym';
     mkdir($subDir1);
     mkdir($subDir2);
     symlink($subDir2, $sym);
     $storage = new \OC\Files\Storage\Local(['datadir' => $subDir1]);
     $storage->file_put_contents('sym/foo', 'bar');
 }