1<?php
2/**
3 * @copyright Copyright (c) 2016, ownCloud, Inc.
4 *
5 * @author Christoph Wurst <christoph@winzerhof-wurst.at>
6 * @author Robin Appelman <robin@icewind.nl>
7 *
8 * @license AGPL-3.0
9 *
10 * This code is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Affero General Public License, version 3,
12 * as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
18 *
19 * You should have received a copy of the GNU Affero General Public License, version 3,
20 * along with this program. If not, see <http://www.gnu.org/licenses/>
21 *
22 */
23namespace OCP\Files\Cache;
24
25/**
26 * check the storage backends for updates and change the cache accordingly
27 *
28 * @since 9.0.0
29 */
30interface IWatcher {
31	public const CHECK_NEVER = 0; // never check the underlying filesystem for updates
32	public const CHECK_ONCE = 1; // check the underlying filesystem for updates once every request for each file
33	public const CHECK_ALWAYS = 2; // always check the underlying filesystem for updates
34
35	/**
36	 * @param int $policy either IWatcher::CHECK_NEVER, IWatcher::CHECK_ONCE, IWatcher::CHECK_ALWAYS
37	 * @since 9.0.0
38	 */
39	public function setPolicy($policy);
40
41	/**
42	 * @return int either IWatcher::CHECK_NEVER, IWatcher::CHECK_ONCE, IWatcher::CHECK_ALWAYS
43	 * @since 9.0.0
44	 */
45	public function getPolicy();
46
47	/**
48	 * check $path for updates and update if needed
49	 *
50	 * @param string $path
51	 * @param ICacheEntry|null $cachedEntry
52	 * @return boolean true if path was updated
53	 * @since 9.0.0
54	 */
55	public function checkUpdate($path, $cachedEntry = null);
56
57	/**
58	 * Update the cache for changes to $path
59	 *
60	 * @param string $path
61	 * @param ICacheEntry $cachedData
62	 * @since 9.0.0
63	 */
64	public function update($path, $cachedData);
65
66	/**
67	 * Check if the cache for $path needs to be updated
68	 *
69	 * @param string $path
70	 * @param ICacheEntry $cachedData
71	 * @return bool
72	 * @since 9.0.0
73	 */
74	public function needsUpdate($path, $cachedData);
75
76	/**
77	 * remove deleted files in $path from the cache
78	 *
79	 * @param string $path
80	 * @since 9.0.0
81	 */
82	public function cleanFolder($path);
83}
84