Common.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Bart Visscher <bartv@thisnet.nl>
  7. * @author Björn Schießle <bjoern@schiessle.org>
  8. * @author hkjolhede <hkjolhede@gmail.com>
  9. * @author Joas Schilling <coding@schilljs.com>
  10. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  11. * @author Lukas Reschke <lukas@statuscode.ch>
  12. * @author Martin Mattel <martin.mattel@diemattels.at>
  13. * @author Michael Gapczynski <GapczynskiM@gmail.com>
  14. * @author Morris Jobke <hey@morrisjobke.de>
  15. * @author Robin Appelman <robin@icewind.nl>
  16. * @author Robin McCorkell <robin@mccorkell.me.uk>
  17. * @author Roeland Jago Douma <roeland@famdouma.nl>
  18. * @author Sam Tuke <mail@samtuke.com>
  19. * @author scambra <sergio@entrecables.com>
  20. * @author Stefan Weil <sw@weilnetz.de>
  21. * @author Thomas Müller <thomas.mueller@tmit.eu>
  22. * @author Vincent Petry <pvince81@owncloud.com>
  23. *
  24. * @license AGPL-3.0
  25. *
  26. * This code is free software: you can redistribute it and/or modify
  27. * it under the terms of the GNU Affero General Public License, version 3,
  28. * as published by the Free Software Foundation.
  29. *
  30. * This program is distributed in the hope that it will be useful,
  31. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  32. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  33. * GNU Affero General Public License for more details.
  34. *
  35. * You should have received a copy of the GNU Affero General Public License, version 3,
  36. * along with this program. If not, see <http://www.gnu.org/licenses/>
  37. *
  38. */
  39. namespace OC\Files\Storage;
  40. use OC\Files\Cache\Cache;
  41. use OC\Files\Cache\Propagator;
  42. use OC\Files\Cache\Scanner;
  43. use OC\Files\Cache\Updater;
  44. use OC\Files\Filesystem;
  45. use OC\Files\Cache\Watcher;
  46. use OCP\Files\EmptyFileNameException;
  47. use OCP\Files\FileNameTooLongException;
  48. use OCP\Files\InvalidCharacterInPathException;
  49. use OCP\Files\InvalidDirectoryException;
  50. use OCP\Files\InvalidPathException;
  51. use OCP\Files\ReservedWordException;
  52. use OCP\Files\Storage\ILockingStorage;
  53. use OCP\Lock\ILockingProvider;
  54. /**
  55. * Storage backend class for providing common filesystem operation methods
  56. * which are not storage-backend specific.
  57. *
  58. * \OC\Files\Storage\Common is never used directly; it is extended by all other
  59. * storage backends, where its methods may be overridden, and additional
  60. * (backend-specific) methods are defined.
  61. *
  62. * Some \OC\Files\Storage\Common methods call functions which are first defined
  63. * in classes which extend it, e.g. $this->stat() .
  64. */
  65. abstract class Common implements Storage, ILockingStorage {
  66. use LocalTempFileTrait;
  67. protected $cache;
  68. protected $scanner;
  69. protected $watcher;
  70. protected $propagator;
  71. protected $storageCache;
  72. protected $updater;
  73. protected $mountOptions = [];
  74. protected $owner = null;
  75. public function __construct($parameters) {
  76. }
  77. /**
  78. * Remove a file or folder
  79. *
  80. * @param string $path
  81. * @return bool
  82. */
  83. protected function remove($path) {
  84. if ($this->is_dir($path)) {
  85. return $this->rmdir($path);
  86. } else if ($this->is_file($path)) {
  87. return $this->unlink($path);
  88. } else {
  89. return false;
  90. }
  91. }
  92. public function is_dir($path) {
  93. return $this->filetype($path) === 'dir';
  94. }
  95. public function is_file($path) {
  96. return $this->filetype($path) === 'file';
  97. }
  98. public function filesize($path) {
  99. if ($this->is_dir($path)) {
  100. return 0; //by definition
  101. } else {
  102. $stat = $this->stat($path);
  103. if (isset($stat['size'])) {
  104. return $stat['size'];
  105. } else {
  106. return 0;
  107. }
  108. }
  109. }
  110. public function isReadable($path) {
  111. // at least check whether it exists
  112. // subclasses might want to implement this more thoroughly
  113. return $this->file_exists($path);
  114. }
  115. public function isUpdatable($path) {
  116. // at least check whether it exists
  117. // subclasses might want to implement this more thoroughly
  118. // a non-existing file/folder isn't updatable
  119. return $this->file_exists($path);
  120. }
  121. public function isCreatable($path) {
  122. if ($this->is_dir($path) && $this->isUpdatable($path)) {
  123. return true;
  124. }
  125. return false;
  126. }
  127. public function isDeletable($path) {
  128. if ($path === '' || $path === '/') {
  129. return false;
  130. }
  131. $parent = dirname($path);
  132. return $this->isUpdatable($parent) && $this->isUpdatable($path);
  133. }
  134. public function isSharable($path) {
  135. return $this->isReadable($path);
  136. }
  137. public function getPermissions($path) {
  138. $permissions = 0;
  139. if ($this->isCreatable($path)) {
  140. $permissions |= \OCP\Constants::PERMISSION_CREATE;
  141. }
  142. if ($this->isReadable($path)) {
  143. $permissions |= \OCP\Constants::PERMISSION_READ;
  144. }
  145. if ($this->isUpdatable($path)) {
  146. $permissions |= \OCP\Constants::PERMISSION_UPDATE;
  147. }
  148. if ($this->isDeletable($path)) {
  149. $permissions |= \OCP\Constants::PERMISSION_DELETE;
  150. }
  151. if ($this->isSharable($path)) {
  152. $permissions |= \OCP\Constants::PERMISSION_SHARE;
  153. }
  154. return $permissions;
  155. }
  156. public function filemtime($path) {
  157. $stat = $this->stat($path);
  158. if (isset($stat['mtime']) && $stat['mtime'] > 0) {
  159. return $stat['mtime'];
  160. } else {
  161. return 0;
  162. }
  163. }
  164. public function file_get_contents($path) {
  165. $handle = $this->fopen($path, "r");
  166. if (!$handle) {
  167. return false;
  168. }
  169. $data = stream_get_contents($handle);
  170. fclose($handle);
  171. return $data;
  172. }
  173. public function file_put_contents($path, $data) {
  174. $handle = $this->fopen($path, "w");
  175. $this->removeCachedFile($path);
  176. $count = fwrite($handle, $data);
  177. fclose($handle);
  178. return $count;
  179. }
  180. public function rename($path1, $path2) {
  181. $this->remove($path2);
  182. $this->removeCachedFile($path1);
  183. return $this->copy($path1, $path2) and $this->remove($path1);
  184. }
  185. public function copy($path1, $path2) {
  186. if ($this->is_dir($path1)) {
  187. $this->remove($path2);
  188. $dir = $this->opendir($path1);
  189. $this->mkdir($path2);
  190. while ($file = readdir($dir)) {
  191. if (!Filesystem::isIgnoredDir($file)) {
  192. if (!$this->copy($path1 . '/' . $file, $path2 . '/' . $file)) {
  193. return false;
  194. }
  195. }
  196. }
  197. closedir($dir);
  198. return true;
  199. } else {
  200. $source = $this->fopen($path1, 'r');
  201. $target = $this->fopen($path2, 'w');
  202. list(, $result) = \OC_Helper::streamCopy($source, $target);
  203. $this->removeCachedFile($path2);
  204. return $result;
  205. }
  206. }
  207. public function getMimeType($path) {
  208. if ($this->is_dir($path)) {
  209. return 'httpd/unix-directory';
  210. } elseif ($this->file_exists($path)) {
  211. return \OC::$server->getMimeTypeDetector()->detectPath($path);
  212. } else {
  213. return false;
  214. }
  215. }
  216. public function hash($type, $path, $raw = false) {
  217. $fh = $this->fopen($path, 'rb');
  218. $ctx = hash_init($type);
  219. hash_update_stream($ctx, $fh);
  220. fclose($fh);
  221. return hash_final($ctx, $raw);
  222. }
  223. public function search($query) {
  224. return $this->searchInDir($query);
  225. }
  226. public function getLocalFile($path) {
  227. return $this->getCachedFile($path);
  228. }
  229. /**
  230. * @param string $path
  231. * @param string $target
  232. */
  233. private function addLocalFolder($path, $target) {
  234. $dh = $this->opendir($path);
  235. if (is_resource($dh)) {
  236. while (($file = readdir($dh)) !== false) {
  237. if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
  238. if ($this->is_dir($path . '/' . $file)) {
  239. mkdir($target . '/' . $file);
  240. $this->addLocalFolder($path . '/' . $file, $target . '/' . $file);
  241. } else {
  242. $tmp = $this->toTmpFile($path . '/' . $file);
  243. rename($tmp, $target . '/' . $file);
  244. }
  245. }
  246. }
  247. }
  248. }
  249. /**
  250. * @param string $query
  251. * @param string $dir
  252. * @return array
  253. */
  254. protected function searchInDir($query, $dir = '') {
  255. $files = array();
  256. $dh = $this->opendir($dir);
  257. if (is_resource($dh)) {
  258. while (($item = readdir($dh)) !== false) {
  259. if (\OC\Files\Filesystem::isIgnoredDir($item)) continue;
  260. if (strstr(strtolower($item), strtolower($query)) !== false) {
  261. $files[] = $dir . '/' . $item;
  262. }
  263. if ($this->is_dir($dir . '/' . $item)) {
  264. $files = array_merge($files, $this->searchInDir($query, $dir . '/' . $item));
  265. }
  266. }
  267. }
  268. closedir($dh);
  269. return $files;
  270. }
  271. /**
  272. * check if a file or folder has been updated since $time
  273. *
  274. * The method is only used to check if the cache needs to be updated. Storage backends that don't support checking
  275. * the mtime should always return false here. As a result storage implementations that always return false expect
  276. * exclusive access to the backend and will not pick up files that have been added in a way that circumvents
  277. * ownClouds filesystem.
  278. *
  279. * @param string $path
  280. * @param int $time
  281. * @return bool
  282. */
  283. public function hasUpdated($path, $time) {
  284. return $this->filemtime($path) > $time;
  285. }
  286. public function getCache($path = '', $storage = null) {
  287. if (!$storage) {
  288. $storage = $this;
  289. }
  290. if (!isset($storage->cache)) {
  291. $storage->cache = new Cache($storage);
  292. }
  293. return $storage->cache;
  294. }
  295. public function getScanner($path = '', $storage = null) {
  296. if (!$storage) {
  297. $storage = $this;
  298. }
  299. if (!isset($storage->scanner)) {
  300. $storage->scanner = new Scanner($storage);
  301. }
  302. return $storage->scanner;
  303. }
  304. public function getWatcher($path = '', $storage = null) {
  305. if (!$storage) {
  306. $storage = $this;
  307. }
  308. if (!isset($this->watcher)) {
  309. $this->watcher = new Watcher($storage);
  310. $globalPolicy = \OC::$server->getConfig()->getSystemValue('filesystem_check_changes', Watcher::CHECK_NEVER);
  311. $this->watcher->setPolicy((int)$this->getMountOption('filesystem_check_changes', $globalPolicy));
  312. }
  313. return $this->watcher;
  314. }
  315. /**
  316. * get a propagator instance for the cache
  317. *
  318. * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
  319. * @return \OC\Files\Cache\Propagator
  320. */
  321. public function getPropagator($storage = null) {
  322. if (!$storage) {
  323. $storage = $this;
  324. }
  325. if (!isset($storage->propagator)) {
  326. $storage->propagator = new Propagator($storage, \OC::$server->getDatabaseConnection());
  327. }
  328. return $storage->propagator;
  329. }
  330. public function getUpdater($storage = null) {
  331. if (!$storage) {
  332. $storage = $this;
  333. }
  334. if (!isset($storage->updater)) {
  335. $storage->updater = new Updater($storage);
  336. }
  337. return $storage->updater;
  338. }
  339. public function getStorageCache($storage = null) {
  340. if (!$storage) {
  341. $storage = $this;
  342. }
  343. if (!isset($this->storageCache)) {
  344. $this->storageCache = new \OC\Files\Cache\Storage($storage);
  345. }
  346. return $this->storageCache;
  347. }
  348. /**
  349. * get the owner of a path
  350. *
  351. * @param string $path The path to get the owner
  352. * @return string|false uid or false
  353. */
  354. public function getOwner($path) {
  355. if ($this->owner === null) {
  356. $this->owner = \OC_User::getUser();
  357. }
  358. return $this->owner;
  359. }
  360. /**
  361. * get the ETag for a file or folder
  362. *
  363. * @param string $path
  364. * @return string
  365. */
  366. public function getETag($path) {
  367. return uniqid();
  368. }
  369. /**
  370. * clean a path, i.e. remove all redundant '.' and '..'
  371. * making sure that it can't point to higher than '/'
  372. *
  373. * @param string $path The path to clean
  374. * @return string cleaned path
  375. */
  376. public function cleanPath($path) {
  377. if (strlen($path) == 0 or $path[0] != '/') {
  378. $path = '/' . $path;
  379. }
  380. $output = array();
  381. foreach (explode('/', $path) as $chunk) {
  382. if ($chunk == '..') {
  383. array_pop($output);
  384. } else if ($chunk == '.') {
  385. } else {
  386. $output[] = $chunk;
  387. }
  388. }
  389. return implode('/', $output);
  390. }
  391. /**
  392. * Test a storage for availability
  393. *
  394. * @return bool
  395. */
  396. public function test() {
  397. if ($this->stat('')) {
  398. return true;
  399. }
  400. return false;
  401. }
  402. /**
  403. * get the free space in the storage
  404. *
  405. * @param string $path
  406. * @return int|false
  407. */
  408. public function free_space($path) {
  409. return \OCP\Files\FileInfo::SPACE_UNKNOWN;
  410. }
  411. /**
  412. * {@inheritdoc}
  413. */
  414. public function isLocal() {
  415. // the common implementation returns a temporary file by
  416. // default, which is not local
  417. return false;
  418. }
  419. /**
  420. * Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class
  421. *
  422. * @param string $class
  423. * @return bool
  424. */
  425. public function instanceOfStorage($class) {
  426. if (ltrim($class, '\\') === 'OC\Files\Storage\Shared') {
  427. // FIXME Temporary fix to keep existing checks working
  428. $class = '\OCA\Files_Sharing\SharedStorage';
  429. }
  430. return is_a($this, $class);
  431. }
  432. /**
  433. * A custom storage implementation can return an url for direct download of a give file.
  434. *
  435. * For now the returned array can hold the parameter url - in future more attributes might follow.
  436. *
  437. * @param string $path
  438. * @return array|false
  439. */
  440. public function getDirectDownload($path) {
  441. return [];
  442. }
  443. /**
  444. * @inheritdoc
  445. * @throws InvalidPathException
  446. */
  447. public function verifyPath($path, $fileName) {
  448. // verify empty and dot files
  449. $trimmed = trim($fileName);
  450. if ($trimmed === '') {
  451. throw new EmptyFileNameException();
  452. }
  453. if (\OC\Files\Filesystem::isIgnoredDir($trimmed)) {
  454. throw new InvalidDirectoryException();
  455. }
  456. if (!\OC::$server->getDatabaseConnection()->supports4ByteText()) {
  457. // verify database - e.g. mysql only 3-byte chars
  458. if (preg_match('%(?:
  459. \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
  460. | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
  461. | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
  462. )%xs', $fileName)) {
  463. throw new InvalidCharacterInPathException();
  464. }
  465. }
  466. if (isset($fileName[255])) {
  467. throw new FileNameTooLongException();
  468. }
  469. // NOTE: $path will remain unverified for now
  470. $this->verifyPosixPath($fileName);
  471. }
  472. /**
  473. * @param string $fileName
  474. * @throws InvalidPathException
  475. */
  476. protected function verifyPosixPath($fileName) {
  477. $fileName = trim($fileName);
  478. $this->scanForInvalidCharacters($fileName, "\\/");
  479. $reservedNames = ['*'];
  480. if (in_array($fileName, $reservedNames)) {
  481. throw new ReservedWordException();
  482. }
  483. }
  484. /**
  485. * @param string $fileName
  486. * @param string $invalidChars
  487. * @throws InvalidPathException
  488. */
  489. private function scanForInvalidCharacters($fileName, $invalidChars) {
  490. foreach (str_split($invalidChars) as $char) {
  491. if (strpos($fileName, $char) !== false) {
  492. throw new InvalidCharacterInPathException();
  493. }
  494. }
  495. $sanitizedFileName = filter_var($fileName, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW);
  496. if ($sanitizedFileName !== $fileName) {
  497. throw new InvalidCharacterInPathException();
  498. }
  499. }
  500. /**
  501. * @param array $options
  502. */
  503. public function setMountOptions(array $options) {
  504. $this->mountOptions = $options;
  505. }
  506. /**
  507. * @param string $name
  508. * @param mixed $default
  509. * @return mixed
  510. */
  511. public function getMountOption($name, $default = null) {
  512. return isset($this->mountOptions[$name]) ? $this->mountOptions[$name] : $default;
  513. }
  514. /**
  515. * @param \OCP\Files\Storage $sourceStorage
  516. * @param string $sourceInternalPath
  517. * @param string $targetInternalPath
  518. * @param bool $preserveMtime
  519. * @return bool
  520. */
  521. public function copyFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) {
  522. if ($sourceStorage === $this) {
  523. return $this->copy($sourceInternalPath, $targetInternalPath);
  524. }
  525. if ($sourceStorage->is_dir($sourceInternalPath)) {
  526. $dh = $sourceStorage->opendir($sourceInternalPath);
  527. $result = $this->mkdir($targetInternalPath);
  528. if (is_resource($dh)) {
  529. while ($result and ($file = readdir($dh)) !== false) {
  530. if (!Filesystem::isIgnoredDir($file)) {
  531. $result &= $this->copyFromStorage($sourceStorage, $sourceInternalPath . '/' . $file, $targetInternalPath . '/' . $file);
  532. }
  533. }
  534. }
  535. } else {
  536. $source = $sourceStorage->fopen($sourceInternalPath, 'r');
  537. // TODO: call fopen in a way that we execute again all storage wrappers
  538. // to avoid that we bypass storage wrappers which perform important actions
  539. // for this operation. Same is true for all other operations which
  540. // are not the same as the original one.Once this is fixed we also
  541. // need to adjust the encryption wrapper.
  542. $target = $this->fopen($targetInternalPath, 'w');
  543. list(, $result) = \OC_Helper::streamCopy($source, $target);
  544. if ($result and $preserveMtime) {
  545. $this->touch($targetInternalPath, $sourceStorage->filemtime($sourceInternalPath));
  546. }
  547. fclose($source);
  548. fclose($target);
  549. if (!$result) {
  550. // delete partially written target file
  551. $this->unlink($targetInternalPath);
  552. // delete cache entry that was created by fopen
  553. $this->getCache()->remove($targetInternalPath);
  554. }
  555. }
  556. return (bool)$result;
  557. }
  558. /**
  559. * @param \OCP\Files\Storage $sourceStorage
  560. * @param string $sourceInternalPath
  561. * @param string $targetInternalPath
  562. * @return bool
  563. */
  564. public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
  565. if ($sourceStorage === $this) {
  566. return $this->rename($sourceInternalPath, $targetInternalPath);
  567. }
  568. if (!$sourceStorage->isDeletable($sourceInternalPath)) {
  569. return false;
  570. }
  571. $result = $this->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, true);
  572. if ($result) {
  573. if ($sourceStorage->is_dir($sourceInternalPath)) {
  574. $result &= $sourceStorage->rmdir($sourceInternalPath);
  575. } else {
  576. $result &= $sourceStorage->unlink($sourceInternalPath);
  577. }
  578. }
  579. return $result;
  580. }
  581. /**
  582. * @inheritdoc
  583. */
  584. public function getMetaData($path) {
  585. $permissions = $this->getPermissions($path);
  586. if (!$permissions & \OCP\Constants::PERMISSION_READ) {
  587. //can't read, nothing we can do
  588. return null;
  589. }
  590. $data = [];
  591. $data['mimetype'] = $this->getMimeType($path);
  592. $data['mtime'] = $this->filemtime($path);
  593. if ($data['mtime'] === false) {
  594. $data['mtime'] = time();
  595. }
  596. if ($data['mimetype'] == 'httpd/unix-directory') {
  597. $data['size'] = -1; //unknown
  598. } else {
  599. $data['size'] = $this->filesize($path);
  600. }
  601. $data['etag'] = $this->getETag($path);
  602. $data['storage_mtime'] = $data['mtime'];
  603. $data['permissions'] = $permissions;
  604. return $data;
  605. }
  606. /**
  607. * @param string $path
  608. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  609. * @param \OCP\Lock\ILockingProvider $provider
  610. * @throws \OCP\Lock\LockedException
  611. */
  612. public function acquireLock($path, $type, ILockingProvider $provider) {
  613. $provider->acquireLock('files/' . md5($this->getId() . '::' . trim($path, '/')), $type);
  614. }
  615. /**
  616. * @param string $path
  617. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  618. * @param \OCP\Lock\ILockingProvider $provider
  619. */
  620. public function releaseLock($path, $type, ILockingProvider $provider) {
  621. $provider->releaseLock('files/' . md5($this->getId() . '::' . trim($path, '/')), $type);
  622. }
  623. /**
  624. * @param string $path
  625. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  626. * @param \OCP\Lock\ILockingProvider $provider
  627. */
  628. public function changeLock($path, $type, ILockingProvider $provider) {
  629. $provider->changeLock('files/' . md5($this->getId() . '::' . trim($path, '/')), $type);
  630. }
  631. /**
  632. * @return array [ available, last_checked ]
  633. */
  634. public function getAvailability() {
  635. return $this->getStorageCache()->getAvailability();
  636. }
  637. /**
  638. * @param bool $isAvailable
  639. */
  640. public function setAvailability($isAvailable) {
  641. $this->getStorageCache()->setAvailability($isAvailable);
  642. }
  643. }