Filesystem.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  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 Christopher Schäpers <kondou@ts.unde.re>
  8. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  9. * @author Florin Peter <github@florin-peter.de>
  10. * @author Joas Schilling <coding@schilljs.com>
  11. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  12. * @author korelstar <korelstar@users.noreply.github.com>
  13. * @author Lukas Reschke <lukas@statuscode.ch>
  14. * @author Michael Gapczynski <GapczynskiM@gmail.com>
  15. * @author Morris Jobke <hey@morrisjobke.de>
  16. * @author Robin Appelman <robin@icewind.nl>
  17. * @author Robin McCorkell <robin@mccorkell.me.uk>
  18. * @author Roeland Jago Douma <roeland@famdouma.nl>
  19. * @author Sam Tuke <mail@samtuke.com>
  20. * @author Stephan Peijnik <speijnik@anexia-it.com>
  21. * @author Vincent Petry <vincent@nextcloud.com>
  22. *
  23. * @license AGPL-3.0
  24. *
  25. * This code is free software: you can redistribute it and/or modify
  26. * it under the terms of the GNU Affero General Public License, version 3,
  27. * as published by the Free Software Foundation.
  28. *
  29. * This program is distributed in the hope that it will be useful,
  30. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  31. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  32. * GNU Affero General Public License for more details.
  33. *
  34. * You should have received a copy of the GNU Affero General Public License, version 3,
  35. * along with this program. If not, see <http://www.gnu.org/licenses/>
  36. *
  37. */
  38. namespace OC\Files;
  39. use OC\Files\Mount\MountPoint;
  40. use OC\User\NoUserException;
  41. use OCP\Cache\CappedMemoryCache;
  42. use OCP\EventDispatcher\IEventDispatcher;
  43. use OCP\Files\Events\Node\FilesystemTornDownEvent;
  44. use OCP\Files\Mount\IMountManager;
  45. use OCP\Files\NotFoundException;
  46. use OCP\Files\Storage\IStorageFactory;
  47. use OCP\IUser;
  48. use OCP\IUserManager;
  49. use OCP\IUserSession;
  50. use Psr\Log\LoggerInterface;
  51. class Filesystem {
  52. private static ?Mount\Manager $mounts = null;
  53. public static bool $loaded = false;
  54. private static ?View $defaultInstance = null;
  55. private static ?CappedMemoryCache $normalizedPathCache = null;
  56. /** @var string[]|null */
  57. private static ?array $blacklist = null;
  58. /**
  59. * classname which used for hooks handling
  60. * used as signalclass in OC_Hooks::emit()
  61. */
  62. public const CLASSNAME = 'OC_Filesystem';
  63. /**
  64. * signalname emitted before file renaming
  65. *
  66. * @param string $oldpath
  67. * @param string $newpath
  68. */
  69. public const signal_rename = 'rename';
  70. /**
  71. * signal emitted after file renaming
  72. *
  73. * @param string $oldpath
  74. * @param string $newpath
  75. */
  76. public const signal_post_rename = 'post_rename';
  77. /**
  78. * signal emitted before file/dir creation
  79. *
  80. * @param string $path
  81. * @param bool $run changing this flag to false in hook handler will cancel event
  82. */
  83. public const signal_create = 'create';
  84. /**
  85. * signal emitted after file/dir creation
  86. *
  87. * @param string $path
  88. * @param bool $run changing this flag to false in hook handler will cancel event
  89. */
  90. public const signal_post_create = 'post_create';
  91. /**
  92. * signal emits before file/dir copy
  93. *
  94. * @param string $oldpath
  95. * @param string $newpath
  96. * @param bool $run changing this flag to false in hook handler will cancel event
  97. */
  98. public const signal_copy = 'copy';
  99. /**
  100. * signal emits after file/dir copy
  101. *
  102. * @param string $oldpath
  103. * @param string $newpath
  104. */
  105. public const signal_post_copy = 'post_copy';
  106. /**
  107. * signal emits before file/dir save
  108. *
  109. * @param string $path
  110. * @param bool $run changing this flag to false in hook handler will cancel event
  111. */
  112. public const signal_write = 'write';
  113. /**
  114. * signal emits after file/dir save
  115. *
  116. * @param string $path
  117. */
  118. public const signal_post_write = 'post_write';
  119. /**
  120. * signal emitted before file/dir update
  121. *
  122. * @param string $path
  123. * @param bool $run changing this flag to false in hook handler will cancel event
  124. */
  125. public const signal_update = 'update';
  126. /**
  127. * signal emitted after file/dir update
  128. *
  129. * @param string $path
  130. * @param bool $run changing this flag to false in hook handler will cancel event
  131. */
  132. public const signal_post_update = 'post_update';
  133. /**
  134. * signal emits when reading file/dir
  135. *
  136. * @param string $path
  137. */
  138. public const signal_read = 'read';
  139. /**
  140. * signal emits when removing file/dir
  141. *
  142. * @param string $path
  143. */
  144. public const signal_delete = 'delete';
  145. /**
  146. * parameters definitions for signals
  147. */
  148. public const signal_param_path = 'path';
  149. public const signal_param_oldpath = 'oldpath';
  150. public const signal_param_newpath = 'newpath';
  151. /**
  152. * run - changing this flag to false in hook handler will cancel event
  153. */
  154. public const signal_param_run = 'run';
  155. public const signal_create_mount = 'create_mount';
  156. public const signal_delete_mount = 'delete_mount';
  157. public const signal_param_mount_type = 'mounttype';
  158. public const signal_param_users = 'users';
  159. private static ?\OC\Files\Storage\StorageFactory $loader = null;
  160. private static bool $logWarningWhenAddingStorageWrapper = true;
  161. /**
  162. * @param bool $shouldLog
  163. * @return bool previous value
  164. * @internal
  165. */
  166. public static function logWarningWhenAddingStorageWrapper(bool $shouldLog): bool {
  167. $previousValue = self::$logWarningWhenAddingStorageWrapper;
  168. self::$logWarningWhenAddingStorageWrapper = $shouldLog;
  169. return $previousValue;
  170. }
  171. /**
  172. * @param string $wrapperName
  173. * @param callable $wrapper
  174. * @param int $priority
  175. */
  176. public static function addStorageWrapper($wrapperName, $wrapper, $priority = 50) {
  177. if (self::$logWarningWhenAddingStorageWrapper) {
  178. \OCP\Server::get(LoggerInterface::class)->warning("Storage wrapper '{wrapper}' was not registered via the 'OC_Filesystem - preSetup' hook which could cause potential problems.", [
  179. 'wrapper' => $wrapperName,
  180. 'app' => 'filesystem',
  181. ]);
  182. }
  183. $mounts = self::getMountManager()->getAll();
  184. if (!self::getLoader()->addStorageWrapper($wrapperName, $wrapper, $priority, $mounts)) {
  185. // do not re-wrap if storage with this name already existed
  186. return;
  187. }
  188. }
  189. /**
  190. * Returns the storage factory
  191. *
  192. * @return IStorageFactory
  193. */
  194. public static function getLoader() {
  195. if (!self::$loader) {
  196. self::$loader = \OC::$server->get(IStorageFactory::class);
  197. }
  198. return self::$loader;
  199. }
  200. /**
  201. * Returns the mount manager
  202. */
  203. public static function getMountManager(): Mount\Manager {
  204. self::initMountManager();
  205. assert(self::$mounts !== null);
  206. return self::$mounts;
  207. }
  208. /**
  209. * get the mountpoint of the storage object for a path
  210. * ( note: because a storage is not always mounted inside the fakeroot, the
  211. * returned mountpoint is relative to the absolute root of the filesystem
  212. * and doesn't take the chroot into account )
  213. *
  214. * @param string $path
  215. * @return string
  216. */
  217. public static function getMountPoint($path) {
  218. if (!self::$mounts) {
  219. \OC_Util::setupFS();
  220. }
  221. $mount = self::$mounts->find($path);
  222. return $mount->getMountPoint();
  223. }
  224. /**
  225. * get a list of all mount points in a directory
  226. *
  227. * @param string $path
  228. * @return string[]
  229. */
  230. public static function getMountPoints($path) {
  231. if (!self::$mounts) {
  232. \OC_Util::setupFS();
  233. }
  234. $result = [];
  235. $mounts = self::$mounts->findIn($path);
  236. foreach ($mounts as $mount) {
  237. $result[] = $mount->getMountPoint();
  238. }
  239. return $result;
  240. }
  241. /**
  242. * get the storage mounted at $mountPoint
  243. *
  244. * @param string $mountPoint
  245. * @return \OC\Files\Storage\Storage|null
  246. */
  247. public static function getStorage($mountPoint) {
  248. $mount = self::getMountManager()->find($mountPoint);
  249. return $mount->getStorage();
  250. }
  251. /**
  252. * @param string $id
  253. * @return Mount\MountPoint[]
  254. */
  255. public static function getMountByStorageId($id) {
  256. return self::getMountManager()->findByStorageId($id);
  257. }
  258. /**
  259. * @param int $id
  260. * @return Mount\MountPoint[]
  261. */
  262. public static function getMountByNumericId($id) {
  263. return self::getMountManager()->findByNumericId($id);
  264. }
  265. /**
  266. * resolve a path to a storage and internal path
  267. *
  268. * @param string $path
  269. * @return array{?\OCP\Files\Storage\IStorage, string} an array consisting of the storage and the internal path
  270. */
  271. public static function resolvePath($path): array {
  272. $mount = self::getMountManager()->find($path);
  273. return [$mount->getStorage(), rtrim($mount->getInternalPath($path), '/')];
  274. }
  275. public static function init(string|IUser|null $user, string $root): bool {
  276. if (self::$defaultInstance) {
  277. return false;
  278. }
  279. self::initInternal($root);
  280. //load custom mount config
  281. self::initMountPoints($user);
  282. return true;
  283. }
  284. public static function initInternal(string $root): bool {
  285. if (self::$defaultInstance) {
  286. return false;
  287. }
  288. self::getLoader();
  289. self::$defaultInstance = new View($root);
  290. /** @var IEventDispatcher $eventDispatcher */
  291. $eventDispatcher = \OC::$server->get(IEventDispatcher::class);
  292. $eventDispatcher->addListener(FilesystemTornDownEvent::class, function () {
  293. self::$defaultInstance = null;
  294. self::$loaded = false;
  295. });
  296. self::initMountManager();
  297. self::$loaded = true;
  298. return true;
  299. }
  300. public static function initMountManager(): void {
  301. if (!self::$mounts) {
  302. self::$mounts = \OC::$server->get(IMountManager::class);
  303. }
  304. }
  305. /**
  306. * Initialize system and personal mount points for a user
  307. *
  308. * @throws \OC\User\NoUserException if the user is not available
  309. */
  310. public static function initMountPoints(string|IUser|null $user = ''): void {
  311. /** @var IUserManager $userManager */
  312. $userManager = \OC::$server->get(IUserManager::class);
  313. $userObject = ($user instanceof IUser) ? $user : $userManager->get($user);
  314. if ($userObject) {
  315. /** @var SetupManager $setupManager */
  316. $setupManager = \OC::$server->get(SetupManager::class);
  317. $setupManager->setupForUser($userObject);
  318. } else {
  319. throw new NoUserException();
  320. }
  321. }
  322. /**
  323. * Get the default filesystem view
  324. */
  325. public static function getView(): ?View {
  326. if (!self::$defaultInstance) {
  327. /** @var IUserSession $session */
  328. $session = \OC::$server->get(IUserSession::class);
  329. $user = $session->getUser();
  330. if ($user) {
  331. $userDir = '/' . $user->getUID() . '/files';
  332. self::initInternal($userDir);
  333. }
  334. }
  335. return self::$defaultInstance;
  336. }
  337. /**
  338. * tear down the filesystem, removing all storage providers
  339. */
  340. public static function tearDown() {
  341. \OC_Util::tearDownFS();
  342. }
  343. /**
  344. * get the relative path of the root data directory for the current user
  345. *
  346. * @return ?string
  347. *
  348. * Returns path like /admin/files
  349. */
  350. public static function getRoot() {
  351. if (!self::$defaultInstance) {
  352. return null;
  353. }
  354. return self::$defaultInstance->getRoot();
  355. }
  356. /**
  357. * mount an \OC\Files\Storage\Storage in our virtual filesystem
  358. *
  359. * @param \OC\Files\Storage\Storage|string $class
  360. * @param array $arguments
  361. * @param string $mountpoint
  362. */
  363. public static function mount($class, $arguments, $mountpoint) {
  364. if (!self::$mounts) {
  365. \OC_Util::setupFS();
  366. }
  367. $mount = new Mount\MountPoint($class, $mountpoint, $arguments, self::getLoader());
  368. self::$mounts->addMount($mount);
  369. }
  370. /**
  371. * return the path to a local version of the file
  372. * we need this because we can't know if a file is stored local or not from
  373. * outside the filestorage and for some purposes a local file is needed
  374. */
  375. public static function getLocalFile(string $path): string|false {
  376. return self::$defaultInstance->getLocalFile($path);
  377. }
  378. /**
  379. * return path to file which reflects one visible in browser
  380. *
  381. * @param string $path
  382. * @return string
  383. */
  384. public static function getLocalPath($path) {
  385. $datadir = \OC_User::getHome(\OC_User::getUser()) . '/files';
  386. $newpath = $path;
  387. if (strncmp($newpath, $datadir, strlen($datadir)) == 0) {
  388. $newpath = substr($path, strlen($datadir));
  389. }
  390. return $newpath;
  391. }
  392. /**
  393. * check if the requested path is valid
  394. *
  395. * @param string $path
  396. * @return bool
  397. */
  398. public static function isValidPath($path) {
  399. $path = self::normalizePath($path);
  400. if (!$path || $path[0] !== '/') {
  401. $path = '/' . $path;
  402. }
  403. if (str_contains($path, '/../') || strrchr($path, '/') === '/..') {
  404. return false;
  405. }
  406. return true;
  407. }
  408. /**
  409. * @param string $filename
  410. * @return bool
  411. */
  412. public static function isFileBlacklisted($filename) {
  413. $filename = self::normalizePath($filename);
  414. if (self::$blacklist === null) {
  415. self::$blacklist = \OC::$server->getConfig()->getSystemValue('blacklisted_files', ['.htaccess']);
  416. }
  417. $filename = strtolower(basename($filename));
  418. return in_array($filename, self::$blacklist);
  419. }
  420. /**
  421. * check if the directory should be ignored when scanning
  422. * NOTE: the special directories . and .. would cause never ending recursion
  423. *
  424. * @param string $dir
  425. * @return boolean
  426. */
  427. public static function isIgnoredDir($dir) {
  428. if ($dir === '.' || $dir === '..') {
  429. return true;
  430. }
  431. return false;
  432. }
  433. /**
  434. * following functions are equivalent to their php builtin equivalents for arguments/return values.
  435. */
  436. public static function mkdir($path) {
  437. return self::$defaultInstance->mkdir($path);
  438. }
  439. public static function rmdir($path) {
  440. return self::$defaultInstance->rmdir($path);
  441. }
  442. public static function is_dir($path) {
  443. return self::$defaultInstance->is_dir($path);
  444. }
  445. public static function is_file($path) {
  446. return self::$defaultInstance->is_file($path);
  447. }
  448. public static function stat($path) {
  449. return self::$defaultInstance->stat($path);
  450. }
  451. public static function filetype($path) {
  452. return self::$defaultInstance->filetype($path);
  453. }
  454. public static function filesize($path) {
  455. return self::$defaultInstance->filesize($path);
  456. }
  457. public static function readfile($path) {
  458. return self::$defaultInstance->readfile($path);
  459. }
  460. public static function isCreatable($path) {
  461. return self::$defaultInstance->isCreatable($path);
  462. }
  463. public static function isReadable($path) {
  464. return self::$defaultInstance->isReadable($path);
  465. }
  466. public static function isUpdatable($path) {
  467. return self::$defaultInstance->isUpdatable($path);
  468. }
  469. public static function isDeletable($path) {
  470. return self::$defaultInstance->isDeletable($path);
  471. }
  472. public static function isSharable($path) {
  473. return self::$defaultInstance->isSharable($path);
  474. }
  475. public static function file_exists($path) {
  476. return self::$defaultInstance->file_exists($path);
  477. }
  478. public static function filemtime($path) {
  479. return self::$defaultInstance->filemtime($path);
  480. }
  481. public static function touch($path, $mtime = null) {
  482. return self::$defaultInstance->touch($path, $mtime);
  483. }
  484. /**
  485. * @return string|false
  486. */
  487. public static function file_get_contents($path) {
  488. return self::$defaultInstance->file_get_contents($path);
  489. }
  490. public static function file_put_contents($path, $data) {
  491. return self::$defaultInstance->file_put_contents($path, $data);
  492. }
  493. public static function unlink($path) {
  494. return self::$defaultInstance->unlink($path);
  495. }
  496. public static function rename($source, $target) {
  497. return self::$defaultInstance->rename($source, $target);
  498. }
  499. public static function copy($source, $target) {
  500. return self::$defaultInstance->copy($source, $target);
  501. }
  502. public static function fopen($path, $mode) {
  503. return self::$defaultInstance->fopen($path, $mode);
  504. }
  505. /**
  506. * @param string $path
  507. * @throws \OCP\Files\InvalidPathException
  508. */
  509. public static function toTmpFile($path): string|false {
  510. return self::$defaultInstance->toTmpFile($path);
  511. }
  512. public static function fromTmpFile($tmpFile, $path) {
  513. return self::$defaultInstance->fromTmpFile($tmpFile, $path);
  514. }
  515. public static function getMimeType($path) {
  516. return self::$defaultInstance->getMimeType($path);
  517. }
  518. public static function hash($type, $path, $raw = false) {
  519. return self::$defaultInstance->hash($type, $path, $raw);
  520. }
  521. public static function free_space($path = '/') {
  522. return self::$defaultInstance->free_space($path);
  523. }
  524. public static function search($query) {
  525. return self::$defaultInstance->search($query);
  526. }
  527. /**
  528. * @param string $query
  529. */
  530. public static function searchByMime($query) {
  531. return self::$defaultInstance->searchByMime($query);
  532. }
  533. /**
  534. * @param string|int $tag name or tag id
  535. * @param string $userId owner of the tags
  536. * @return FileInfo[] array or file info
  537. */
  538. public static function searchByTag($tag, $userId) {
  539. return self::$defaultInstance->searchByTag($tag, $userId);
  540. }
  541. /**
  542. * check if a file or folder has been updated since $time
  543. *
  544. * @param string $path
  545. * @param int $time
  546. * @return bool
  547. */
  548. public static function hasUpdated($path, $time) {
  549. return self::$defaultInstance->hasUpdated($path, $time);
  550. }
  551. /**
  552. * Fix common problems with a file path
  553. *
  554. * @param string $path
  555. * @param bool $stripTrailingSlash whether to strip the trailing slash
  556. * @param bool $isAbsolutePath whether the given path is absolute
  557. * @param bool $keepUnicode true to disable unicode normalization
  558. * @psalm-taint-escape file
  559. * @return string
  560. */
  561. public static function normalizePath($path, $stripTrailingSlash = true, $isAbsolutePath = false, $keepUnicode = false) {
  562. /**
  563. * FIXME: This is a workaround for existing classes and files which call
  564. * this function with another type than a valid string. This
  565. * conversion should get removed as soon as all existing
  566. * function calls have been fixed.
  567. */
  568. $path = (string)$path;
  569. if ($path === '') {
  570. return '/';
  571. }
  572. if (is_null(self::$normalizedPathCache)) {
  573. self::$normalizedPathCache = new CappedMemoryCache(2048);
  574. }
  575. $cacheKey = json_encode([$path, $stripTrailingSlash, $isAbsolutePath, $keepUnicode]);
  576. if ($cacheKey && isset(self::$normalizedPathCache[$cacheKey])) {
  577. return self::$normalizedPathCache[$cacheKey];
  578. }
  579. //normalize unicode if possible
  580. if (!$keepUnicode) {
  581. $path = \OC_Util::normalizeUnicode($path);
  582. }
  583. //add leading slash, if it is already there we strip it anyway
  584. $path = '/' . $path;
  585. $patterns = [
  586. '#\\\\#s', // no windows style '\\' slashes
  587. '#/\.(/\.)*/#s', // remove '/./'
  588. '#\//+#s', // remove sequence of slashes
  589. '#/\.$#s', // remove trailing '/.'
  590. ];
  591. do {
  592. $count = 0;
  593. $path = preg_replace($patterns, '/', $path, -1, $count);
  594. } while ($count > 0);
  595. //remove trailing slash
  596. if ($stripTrailingSlash && strlen($path) > 1) {
  597. $path = rtrim($path, '/');
  598. }
  599. self::$normalizedPathCache[$cacheKey] = $path;
  600. return $path;
  601. }
  602. /**
  603. * get the filesystem info
  604. *
  605. * @param string $path
  606. * @param bool|string $includeMountPoints whether to add mountpoint sizes,
  607. * defaults to true
  608. * @return \OC\Files\FileInfo|false False if file does not exist
  609. */
  610. public static function getFileInfo($path, $includeMountPoints = true) {
  611. return self::getView()->getFileInfo($path, $includeMountPoints);
  612. }
  613. /**
  614. * change file metadata
  615. *
  616. * @param string $path
  617. * @param array $data
  618. * @return int
  619. *
  620. * returns the fileid of the updated file
  621. */
  622. public static function putFileInfo($path, $data) {
  623. return self::$defaultInstance->putFileInfo($path, $data);
  624. }
  625. /**
  626. * get the content of a directory
  627. *
  628. * @param string $directory path under datadirectory
  629. * @param string $mimetype_filter limit returned content to this mimetype or mimepart
  630. * @return \OC\Files\FileInfo[]
  631. */
  632. public static function getDirectoryContent($directory, $mimetype_filter = '') {
  633. return self::$defaultInstance->getDirectoryContent($directory, $mimetype_filter);
  634. }
  635. /**
  636. * Get the path of a file by id
  637. *
  638. * Note that the resulting path is not guaranteed to be unique for the id, multiple paths can point to the same file
  639. *
  640. * @param int $id
  641. * @throws NotFoundException
  642. * @return string
  643. */
  644. public static function getPath($id) {
  645. return self::$defaultInstance->getPath($id);
  646. }
  647. /**
  648. * Get the owner for a file or folder
  649. *
  650. * @param string $path
  651. * @return string
  652. */
  653. public static function getOwner($path) {
  654. return self::$defaultInstance->getOwner($path);
  655. }
  656. /**
  657. * get the ETag for a file or folder
  658. */
  659. public static function getETag(string $path): string|false {
  660. return self::$defaultInstance->getETag($path);
  661. }
  662. }