* - Watcher: checks for changes made to the filesystem outside of the ownCloud instance and rescans files and folder when a change is detected
* - Updater: listens to changes made to the filesystem inside of the ownCloud instance and updates the cache where needed
* - ChangePropagator: updates the mtime and etags of parent folders whenever a change to the cache is made to the cache by the updater
+ *
+ * @since 9.0.0
*/
interface ICache {
const NOT_FOUND = 0;
* Get the numeric storage id for this cache's storage
*
* @return int
+ * @since 9.0.0
*/
public function getNumericStorageId();
*
* @param string | int $file either the path of a file or folder or the file id for a file or folder
* @return ICacheEntry[]|false the cache entry or false if the file is not found in the cache
+ * @since 9.0.0
*/
public function get($file);
*
* @param string $folder
* @return ICacheEntry[]
+ * @since 9.0.0
*/
public function getFolderContents($folder);
*
* @param int $fileId the file id of the folder
* @return ICacheEntry[]
+ * @since 9.0.0
*/
public function getFolderContentsById($fileId);
*
* @return int file id
* @throws \RuntimeException
+ * @since 9.0.0
*/
public function put($file, array $data);
*
* @param int $id the fileid of the existing file or folder
* @param array $data [$key => $value] the metadata to update, only the fields provided in the array will be updated, non-provided values will remain unchanged
+ * @since 9.0.0
*/
public function update($id, array $data);
*
* @param string $file
* @return int
+ * @since 9.0.0
*/
public function getId($file);
*
* @param string $file
* @return int
+ * @since 9.0.0
*/
public function getParentId($file);
*
* @param string $file
* @return bool
+ * @since 9.0.0
*/
public function inCache($file);
* when removing a folder from the cache all files and folders inside the folder will be removed as well
*
* @param string $file
+ * @since 9.0.0
*/
public function remove($file);
*
* @param string $source
* @param string $target
+ * @since 9.0.0
*/
public function move($source, $target);
* @param string $sourcePath
* @param string $targetPath
* @throws \OC\DatabaseException
+ * @since 9.0.0
*/
public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath);
/**
* remove all entries for files that are stored on the storage from the cache
+ *
+ * @since 9.0.0
*/
public function clear();
* @param string $file
*
* @return int ICache::NOT_FOUND, ICache::PARTIAL, ICache::SHALLOW or ICache::COMPLETE
+ * @since 9.0.0
*/
public function getStatus($file);
*
* @param string $pattern the search pattern using SQL search syntax (e.g. '%searchstring%')
* @return ICacheEntry[] an array of cache entries where the name matches the search pattern
+ * @since 9.0.0
*/
public function search($pattern);
* @param string $mimetype either a full mimetype to search ('text/plain') or only the first part of a mimetype ('image')
* where it will search for all mimetypes in the group ('image/*')
* @return ICacheEntry[] an array of cache entries where the mimetype matches the search
+ * @since 9.0.0
*/
public function searchByMime($mimetype);
* @param string|int $tag name or tag id
* @param string $userId owner of the tags
* @return ICacheEntry[] file data
+ * @since 9.0.0
*/
public function searchByTag($tag, $userId);
*
* @param string|boolean $path
* @param array $data (optional) meta data of the folder
+ * @since 9.0.0
*/
public function correctFolderSize($path, $data = null);
* @param string $path
* @param array $entry (optional) meta data of the folder
* @return int
+ * @since 9.0.0
*/
public function calculateFolderSize($path, $entry = null);
* get all file ids on the files on the storage
*
* @return int[]
+ * @since 9.0.0
*/
public function getAll();
* likely the folder where we stopped scanning previously
*
* @return string|bool the path of the folder or false when no folder matched
+ * @since 9.0.0
*/
public function getIncomplete();
*
* @param int $id the file id of the file or folder to search
* @return string|null the path of the file (relative to the storage) or null if a file with the given id does not exists within this cache
+ * @since 9.0.0
*/
public function getPathById($id);
*
* @param string $path
* @return string
+ * @since 9.0.0
*/
public function normalize($path);
}
/**
* meta data for a file or folder
+ *
+ * @since 9.0.0
*/
interface ICacheEntry {
/**
* Get the numeric id of a file
*
* @return int
+ * @since 9.0.0
*/
public function getId();
* Get the numeric id for the storage
*
* @return int
+ * @since 9.0.0
*/
public function getStorageId();
* Get the path of the file relative to the storage root
*
* @return string
+ * @since 9.0.0
*/
public function getPath();
* Get the file name
*
* @return string
+ * @since 9.0.0
*/
public function getName();
* Get the full mimetype
*
* @return string
+ * @since 9.0.0
*/
public function getMimeType();
* Get the first part of the mimetype
*
* @return string
+ * @since 9.0.0
*/
public function getMimePart();
* Get the file size in bytes
*
* @return int
+ * @since 9.0.0
*/
public function getSize();
* Get the last modified date as unix timestamp
*
* @return int
+ * @since 9.0.0
*/
public function getMTime();
* This can differ from the mtime on the underlying storage which usually only changes when a direct child is added, removed or renamed
*
* @return int
+ * @since 9.0.0
*/
public function getStorageMTime();
* Etag for folders change whenever a file in the folder has changed
*
* @return string
+ * @since 9.0.0
*/
public function getEtag();
* \OCP\PERMISSION_UPDATE, \OCP\PERMISSION_DELETE and \OCP\PERMISSION_SHARE
*
* @return int
+ * @since 9.0.0
*/
public function getPermissions();
* Check if the file is encrypted
*
* @return bool
+ * @since 9.0.0
*/
public function isEncrypted();
}
/**
* Propagate etags and mtimes within the storage
+ *
+ * @since 9.0.0
*/
interface IPropagator {
/**
* @param string $internalPath
* @param int $time
* @return array[] all propagated cache entries
+ * @since 9.0.0
*/
public function propagateChange($internalPath, $time);
}
/**
* Scan files form the storage and save to the cache
+ *
+ * @since 9.0.0
*/
interface IScanner {
const SCAN_RECURSIVE = true;
* @return array an array of metadata of the scanned file
* @throws \OC\ServerNotAvailableException
* @throws \OCP\Lock\LockedException
+ * @since 9.0.0
*/
public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true);
* @param int $reuse
* @param bool $lock set to false to disable getting an additional read lock during scanning
* @return array an array of the meta data of the scanned file or folder
+ * @since 9.0.0
*/
public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true);
*
* @param string $file
* @return boolean
+ * @since 9.0.0
*/
public static function isPartialFile($file);
/**
* walk over any folders that are not fully scanned yet and scan them
+ *
+ * @since 9.0.0
*/
public function backgroundScan();
}
/**
* Update the cache and propagate changes
*
+ * @since 9.0.0
*/
interface IUpdater {
/**
* Get the propagator for etags and mtime for the view the updater works on
*
* @return IPropagator
+ * @since 9.0.0
*/
public function getPropagator();
*
* @param string $path the path of the file to propagate the changes for
* @param int|null $time the timestamp to set as mtime for the parent folders, if left out the current time is used
+ * @since 9.0.0
*/
public function propagate($path, $time = null);
*
* @param string $path
* @param int $time
+ * @since 9.0.0
*/
public function update($path, $time = null);
* Remove $path from the cache and update the size, etag and mtime of the parent folders
*
* @param string $path
+ * @since 9.0.0
*/
public function remove($path);
* @param \OCP\Files\Storage $sourceStorage
* @param string $source
* @param string $target
+ * @since 9.0.0
*/
public function renameFromStorage(Storage $sourceStorage, $source, $target);
}
/**
* check the storage backends for updates and change the cache accordingly
+ *
+ * @since 9.0.0
*/
interface IWatcher {
const CHECK_NEVER = 0; // never check the underlying filesystem for updates
/**
* @param int $policy either IWatcher::CHECK_NEVER, IWatcher::CHECK_ONCE, IWatcher::CHECK_ALWAYS
+ * @since 9.0.0
*/
public function setPolicy($policy);
/**
* @return int either IWatcher::CHECK_NEVER, IWatcher::CHECK_ONCE, IWatcher::CHECK_ALWAYS
+ * @since 9.0.0
*/
public function getPolicy();
* @param string $path
* @param ICacheEntry|null $cachedEntry
* @return boolean true if path was updated
+ * @since 9.0.0
*/
public function checkUpdate($path, $cachedEntry = null);
*
* @param string $path
* @param ICacheEntry $cachedData
+ * @since 9.0.0
*/
public function update($path, $cachedData);
* @param string $path
* @param ICacheEntry $cachedData
* @return bool
+ * @since 9.0.0
*/
public function needsUpdate($path, $cachedData);
* remove deleted files in $path from the cache
*
* @param string $path
+ * @since 9.0.0
*/
public function cleanFolder($path);
}
/**
* @return ICache
+ * @since 9.0.0
*/
public function getCache();
/**
* @return IPropagator
+ * @since 9.0.0
*/
public function getPropagator();
/**
* @return IScanner
+ * @since 9.0.0
*/
public function getScanner();
/**
* @return IUpdater
+ * @since 9.0.0
*/
public function getUpdater();
/**
* @return IWatcher
+ * @since 9.0.0
*/
public function getWatcher();
}