migrate therinaldos.com data
Build & Deploy to DigitalOcean Space / build (push) Failing after 2m38s

This commit is contained in:
2024-05-05 15:50:45 -04:00
commit ef1ff240d4
23182 changed files with 3801898 additions and 0 deletions
@@ -0,0 +1,35 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
/**
* Exception for already existing files/folders
* @since 6.0.0
*/
class AlreadyExistsException extends \Exception {
}
@@ -0,0 +1,20 @@
<?php
namespace OCP\Files\AppData;
use OCP\Files\IAppData;
/**
* A factory allows you to get the AppData folder for an application.
*
* @since 25.0.0
*/
interface IAppDataFactory {
/**
* Get the AppData folder for the specified $appId
* @param string $appId
* @return IAppData
* @since 25.0.0
*/
public function get(string $appId): IAppData;
}
@@ -0,0 +1,94 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019 Robin Appelman <robin@icewind.nl>
*
* @author Joas Schilling <coding@schilljs.com>
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Cache;
use OCP\EventDispatcher\Event;
use OCP\Files\Storage\IStorage;
/**
* @since 22.0.0
*/
class AbstractCacheEvent extends Event implements ICacheEvent {
protected $storage;
protected $path;
protected $fileId;
protected $storageId;
/**
* @param IStorage $storage
* @param string $path
* @param int $fileId
* @since 22.0.0
*/
public function __construct(IStorage $storage, string $path, int $fileId, int $storageId) {
$this->storage = $storage;
$this->path = $path;
$this->fileId = $fileId;
$this->storageId = $storageId;
}
/**
* @return IStorage
* @since 22.0.0
*/
public function getStorage(): IStorage {
return $this->storage;
}
/**
* @return string
* @since 22.0.0
*/
public function getPath(): string {
return $this->path;
}
/**
* @param string $path
* @since 22.0.0
*/
public function setPath(string $path): void {
$this->path = $path;
}
/**
* @return int
* @since 22.0.0
*/
public function getFileId(): int {
return $this->fileId;
}
/**
* @return int
* @since 22.0.0
*/
public function getStorageId(): int {
return $this->storageId;
}
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl>
*
* @author Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Cache;
/**
* Event for when an existing entry in the cache gets inserted
*
* @since 21.0.0
*/
class CacheEntryInsertedEvent extends AbstractCacheEvent implements ICacheEvent {
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl>
*
* @author Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Cache;
/**
* Event for when an existing entry in the cache gets removed
*
* @since 21.0.0
*/
class CacheEntryRemovedEvent extends AbstractCacheEvent implements ICacheEvent {
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl>
*
* @author Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Cache;
/**
* Event for when an existing entry in the cache gets updated
*
* @since 21.0.0
*/
class CacheEntryUpdatedEvent extends AbstractCacheEvent implements ICacheEvent {
}
@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019 Robin Appelman <robin@icewind.nl>
*
* @author Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Cache;
/**
* Event for when a new entry gets added to the cache
*
* @since 16.0.0
* @deprecated 21.0.0 use CacheEntryInsertedEvent instead
*/
class CacheInsertEvent extends CacheEntryInsertedEvent {
}
@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019 Robin Appelman <robin@icewind.nl>
*
* @author Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Cache;
/**
* Event for when an existing entry in the cache gets updated
*
* @since 16.0.0
* @deprecated 21.0.0 use CacheEntryUpdatedEvent instead
*/
class CacheUpdateEvent extends CacheEntryUpdatedEvent {
}
@@ -0,0 +1,294 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Robin Appelman <robin@icewind.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\Files\Cache;
use OCP\Files\Search\ISearchOperator;
use OCP\Files\Search\ISearchQuery;
/**
* Metadata cache for a storage
*
* The cache stores the metadata for all files and folders in a storage and is kept up to date through the following mechanisms:
*
* - Scanner: scans the storage and updates the cache where needed
* - Watcher: checks for changes made to the filesystem outside of the Nextcloud instance and rescans files and folder when a change is detected
* - Updater: listens to changes made to the filesystem inside of the Nextcloud 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 {
public const NOT_FOUND = 0;
public const PARTIAL = 1; //only partial data available, file not cached in the database
public const SHALLOW = 2; //folder in cache, but not all child files are completely scanned
public const COMPLETE = 3;
/**
* Get the numeric storage id for this cache's storage
*
* @return int
* @since 9.0.0
*/
public function getNumericStorageId();
/**
* get the stored metadata of a file or folder
*
* @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);
/**
* get the metadata of all files stored in $folder
*
* Only returns files one level deep, no recursion
*
* @param string $folder
* @return ICacheEntry[]
* @since 9.0.0
*/
public function getFolderContents($folder);
/**
* get the metadata of all files stored in $folder
*
* Only returns files one level deep, no recursion
*
* @param int $fileId the file id of the folder
* @return ICacheEntry[]
* @since 9.0.0
*/
public function getFolderContentsById($fileId);
/**
* store meta data for a file or folder
* This will automatically call either insert or update depending on if the file exists
*
* @param string $file
* @param array $data
*
* @return int file id
* @throws \RuntimeException
* @since 9.0.0
*/
public function put($file, array $data);
/**
* insert meta data for a new file or folder
*
* @param string $file
* @param array $data
*
* @return int file id
* @throws \RuntimeException
* @since 9.0.0
*/
public function insert($file, array $data);
/**
* update the metadata of an existing file or folder in the cache
*
* @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);
/**
* get the file id for a file
*
* A file id is a numeric id for a file or folder that's unique within an Nextcloud instance which stays the same for the lifetime of a file
*
* File ids are easiest way for apps to store references to a file since unlike paths they are not affected by renames or sharing
*
* @param string $file
* @return int
* @since 9.0.0
*/
public function getId($file);
/**
* get the id of the parent folder of a file
*
* @param string $file
* @return int
* @since 9.0.0
*/
public function getParentId($file);
/**
* check if a file is available in the cache
*
* @param string $file
* @return bool
* @since 9.0.0
*/
public function inCache($file);
/**
* remove a file or folder from the cache
*
* 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);
/**
* Move a file or folder in the cache
*
* @param string $source
* @param string $target
* @since 9.0.0
*/
public function move($source, $target);
/**
* Move a file or folder in the cache
*
* Note that this should make sure the entries are removed from the source cache
*
* @param \OCP\Files\Cache\ICache $sourceCache
* @param string $sourcePath
* @param string $targetPath
* @throws \OC\DatabaseException
* @since 9.0.0
*/
public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath);
/**
* Copy a file or folder in the cache
*
* @param ICache $sourceCache
* @param ICacheEntry $sourceEntry
* @param string $targetPath
* @return int fileid of copied entry
* @since 22.0.0
*/
public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int;
/**
* Get the scan status of a file
*
* - ICache::NOT_FOUND: File is not in the cache
* - ICache::PARTIAL: File is not stored in the cache but some incomplete data is known
* - ICache::SHALLOW: The folder and it's direct children are in the cache but not all sub folders are fully scanned
* - ICache::COMPLETE: The file or folder, with all it's children) are fully scanned
*
* @param string $file
*
* @return int ICache::NOT_FOUND, ICache::PARTIAL, ICache::SHALLOW or ICache::COMPLETE
* @since 9.0.0
*/
public function getStatus($file);
/**
* search for files matching $pattern, files are matched if their filename matches the search pattern
*
* @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
* @deprecated 9.0.0 due to lack of pagination, not all backends might implement this
*/
public function search($pattern);
/**
* search for files by mimetype
*
* @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
* @deprecated 9.0.0 due to lack of pagination, not all backends might implement this
*/
public function searchByMime($mimetype);
/**
* Search for files with a flexible query
*
* @param ISearchQuery $query
* @return ICacheEntry[]
* @throw \InvalidArgumentException if the cache is unable to perform the query
* @since 12.0.0
*/
public function searchQuery(ISearchQuery $query);
/**
* find a folder in the cache which has not been fully scanned
*
* If multiple incomplete folders are in the cache, the one with the highest id will be returned,
* use the one with the highest id gives the best result with the background scanner, since that is most
* likely the folder where we stopped scanning previously
*
* @return string|false the path of the folder or false when no folder matched
* @since 9.0.0
*/
public function getIncomplete();
/**
* get the path of a file on this storage by it's file id
*
* @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);
/**
* normalize the given path for usage in the cache
*
* @param string $path
* @return string
* @since 9.0.0
*/
public function normalize($path);
/**
* Get the query expression required to filter files within this storage.
*
* In the most basic case this is just comparing the storage id
* but storage wrappers can add additional expressions to filter down things further
*
* @return ISearchOperator
* @since 22.0.0
*/
public function getQueryFilterForStorage(): ISearchOperator;
/**
* Construct a cache entry from a search result row *if* the entry belongs to this storage.
*
* This method will be called for every item in the search results, including results from different storages.
* It's the responsibility of this method to return `null` for all results that don't belong to this storage.
*
* Additionally some implementations might need to further process the resulting entry such as modifying the path
* or permissions of the result.
*
* @param ICacheEntry $rawEntry
* @return ICacheEntry|null
* @since 22.0.0
*/
public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry;
}
@@ -0,0 +1,175 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Robin Appelman <robin@icewind.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\Files\Cache;
use ArrayAccess;
/**
* meta data for a file or folder
*
* @since 9.0.0
*
* This interface extends \ArrayAccess since v21.0.0, previous versions only
* implemented it in the private implementation. Hence php would allow using the
* object as array, while strictly speaking it didn't support this.
*/
interface ICacheEntry extends ArrayAccess {
public const DIRECTORY_MIMETYPE = 'httpd/unix-directory';
/**
* 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();
/**
* Get the last modified date on the storage as unix timestamp
*
* Note that when a file is updated we also update the mtime of all parent folders to make it visible to the user which folder has had updates most recently
* 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();
/**
* Get the etag for the file
*
* An etag is used for change detection of files and folders, an etag of a file changes whenever the content of the file changes
* Etag for folders change whenever a file in the folder has changed
*
* @return string
* @since 9.0.0
*/
public function getEtag();
/**
* Get the permissions for the file stored as bitwise combination of \OCP\Constants::PERMISSION_READ, \OCP\Constants::PERMISSION_CREATE
* \OCP\Constants::PERMISSION_UPDATE, \OCP\Constants::PERMISSION_DELETE and \OCP\Constants::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();
/**
* Get the metadata etag for the file
*
* @return string | null
* @since 18.0.0
*/
public function getMetadataEtag(): ?string;
/**
* Get the last modified date as unix timestamp
*
* @return int | null
* @since 18.0.0
*/
public function getCreationTime(): ?int;
/**
* Get the last modified date as unix timestamp
*
* @return int | null
* @since 18.0.0
*/
public function getUploadTime(): ?int;
/**
* Get the unencrypted size
*
* This might be different from the result of getSize
*
* @return int
* @since 25.0.0
*/
public function getUnencryptedSize(): int;
}
@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019 Robin Appelman <robin@icewind.nl>
*
* @author Joas Schilling <coding@schilljs.com>
* @author Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Cache;
use OCP\Files\Storage\IStorage;
/**
* @since 16.0.0
*/
interface ICacheEvent {
/**
* @return IStorage
* @since 16.0.0
*/
public function getStorage(): IStorage;
/**
* @return string
* @since 16.0.0
*/
public function getPath(): string;
/**
* @param string $path
* @since 19.0.0
*/
public function setPath(string $path): void;
/**
* @return int
* @since 16.0.0
*/
public function getFileId(): int;
/**
* @return int
* @since 21.0.0
*/
public function getStorageId(): int;
}
@@ -0,0 +1,56 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Robin Appelman <robin@icewind.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\Files\Cache;
/**
* Propagate etags and mtimes within the storage
*
* @since 9.0.0
*/
interface IPropagator {
/**
* Mark the beginning of a propagation batch
*
* Note that not all cache setups support propagation in which case this will be a noop
*
* Batching for cache setups that do support it has to be explicit since the cache state is not fully consistent
* before the batch is committed.
*
* @since 9.1.0
*/
public function beginBatch();
/**
* Commit the active propagation batch
*
* @since 9.1.0
*/
public function commitBatch();
/**
* @param string $internalPath
* @param int $time
* @param int $sizeDifference
* @since 9.0.0
*/
public function propagateChange($internalPath, $time, $sizeDifference = 0);
}
@@ -0,0 +1,83 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Robin Appelman <robin@icewind.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\Files\Cache;
/**
* Scan files from the storage and save to the cache
*
* @since 9.0.0
*/
interface IScanner {
public const SCAN_RECURSIVE_INCOMPLETE = 2; // only recursive into not fully scanned folders
public const SCAN_RECURSIVE = true;
public const SCAN_SHALLOW = false;
public const REUSE_NONE = 0;
public const REUSE_ETAG = 1;
public const REUSE_SIZE = 2;
/**
* scan a single file and store it in the cache
*
* @param string $file
* @param int $reuseExisting
* @param int $parentId
* @param array | null $cacheData existing data in the cache for the file to be scanned
* @param bool $lock set to false to disable getting an additional read lock during scanning
* @return array | null 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);
/**
* scan a folder and all its children
*
* @param string $path
* @param bool $recursive
* @param int $reuse
* @param bool $lock set to false to disable getting an additional read lock during scanning
* @return array | null 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);
/**
* check if the file should be ignored when scanning
* NOTE: files with a '.part' extension are ignored as well!
* prevents unfinished put requests to be scanned
*
* @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();
}
@@ -0,0 +1,75 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Robin Appelman <robin@icewind.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\Files\Cache;
use OCP\Files\Storage\IStorage;
/**
* 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();
/**
* Propagate etag and mtime changes for the parent folders of $path up to the root of the filesystem
*
* @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);
/**
* Update the cache for $path and update the size, etag and mtime of the parent folders
*
* @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);
/**
* Rename a file or folder in the cache and update the size, etag and mtime of the parent folders
*
* @param IStorage $sourceStorage
* @param string $source
* @param string $target
* @since 9.0.0
*/
public function renameFromStorage(IStorage $sourceStorage, $source, $target);
}
@@ -0,0 +1,83 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Robin Appelman <robin@icewind.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\Files\Cache;
/**
* check the storage backends for updates and change the cache accordingly
*
* @since 9.0.0
*/
interface IWatcher {
public const CHECK_NEVER = 0; // never check the underlying filesystem for updates
public const CHECK_ONCE = 1; // check the underlying filesystem for updates once every request for each file
public const CHECK_ALWAYS = 2; // always 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();
/**
* check $path for updates and update if needed
*
* @param string $path
* @param ICacheEntry|null $cachedEntry
* @return boolean true if path was updated
* @since 9.0.0
*/
public function checkUpdate($path, $cachedEntry = null);
/**
* Update the cache for changes to $path
*
* @param string $path
* @param ICacheEntry $cachedData
* @since 9.0.0
*/
public function update($path, $cachedData);
/**
* Check if the cache for $path needs to be updated
*
* @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);
}
@@ -0,0 +1,44 @@
<?php
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
* @author Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Config;
/**
* Holds information about a mount for a user
*
* @since 13.0.0
*/
interface ICachedMountFileInfo extends ICachedMountInfo {
/**
* Return the path for the file within the cached mount
*
* @return string
* @since 13.0.0
*/
public function getInternalPath(): string;
/**
* @return string
* @since 13.0.0
*/
public function getPath(): string;
}
@@ -0,0 +1,95 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\Files\Config;
use OCP\Files\Node;
use OCP\IUser;
/**
* Holds information about a mount for a user
*
* @since 9.0.0
*/
interface ICachedMountInfo {
/**
* @return IUser
* @since 9.0.0
*/
public function getUser(): IUser;
/**
* @return int the numeric storage id of the mount
* @since 9.0.0
*/
public function getStorageId(): int;
/**
* @return int the fileid of the root of the mount
* @since 9.0.0
*/
public function getRootId(): int;
/**
* @return Node|null the root node of the mount
* @since 9.0.0
*/
public function getMountPointNode(): ?Node;
/**
* @return string the mount point of the mount for the user
* @since 9.0.0
*/
public function getMountPoint(): string;
/**
* Get the id of the configured mount
*
* @return int|null mount id or null if not applicable
* @since 9.1.0
*/
public function getMountId(): ?int;
/**
* Get the internal path (within the storage) of the root of the mount
*
* @return string
* @since 11.0.0
*/
public function getRootInternalPath(): string;
/**
* Get the class of the mount provider that this mount originates from
*
* @return string
* @since 24.0.0
*/
public function getMountProvider(): string;
/**
* Get a key that uniquely identifies the mount
*
* @return string
* @since 28.0.0
*/
public function getKey(): string;
}
@@ -0,0 +1,42 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Robin Appelman <robin@icewind.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\Files\Config;
use OCP\Files\Storage\IStorageFactory;
use OCP\IUser;
/**
* Provides
*
* @since 9.1.0
*/
interface IHomeMountProvider {
/**
* Get all mountpoints applicable for the user
*
* @param \OCP\IUser $user
* @param \OCP\Files\Storage\IStorageFactory $loader
* @return \OCP\Files\Mount\IMountPoint|null
* @since 9.1.0
*/
public function getHomeMountForUser(IUser $user, IStorageFactory $loader);
}
@@ -0,0 +1,42 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\Files\Config;
use OCP\Files\Storage\IStorageFactory;
use OCP\IUser;
/**
* Provides
* @since 8.0.0
*/
interface IMountProvider {
/**
* Get all mountpoints applicable for the user
*
* @param \OCP\IUser $user
* @param \OCP\Files\Storage\IStorageFactory $loader
* @return \OCP\Files\Mount\IMountPoint[]
* @since 8.0.0
*/
public function getMountsForUser(IUser $user, IStorageFactory $loader);
}
@@ -0,0 +1,99 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\Files\Config;
use OCP\IUser;
/**
* Manages the different mount providers
* @since 8.0.0
*/
interface IMountProviderCollection {
/**
* Get all configured mount points for the user
*
* @param \OCP\IUser $user
* @return \OCP\Files\Mount\IMountPoint[]
* @since 8.0.0
*/
public function getMountsForUser(IUser $user);
/**
* Get the configured mount points for the user from a specific mount provider
*
* @param \OCP\IUser $user
* @param class-string<IMountProvider>[] $mountProviderClasses
* @return \OCP\Files\Mount\IMountPoint[]
* @since 24.0.0
*/
public function getUserMountsForProviderClasses(IUser $user, array $mountProviderClasses): array;
/**
* Get the configured home mount for this user
*
* @param \OCP\IUser $user
* @return \OCP\Files\Mount\IMountPoint
* @since 9.1.0
*/
public function getHomeMountForUser(IUser $user);
/**
* Add a provider for mount points
*
* @param \OCP\Files\Config\IMountProvider $provider
* @since 8.0.0
*/
public function registerProvider(IMountProvider $provider);
/**
* Add a filter for mounts
*
* @param callable $filter (IMountPoint $mountPoint, IUser $user) => boolean
* @since 14.0.0
*/
public function registerMountFilter(callable $filter);
/**
* Add a provider for home mount points
*
* @param \OCP\Files\Config\IHomeMountProvider $provider
* @since 9.1.0
*/
public function registerHomeProvider(IHomeMountProvider $provider);
/**
* Get the mount cache which can be used to search for mounts without setting up the filesystem
*
* @return IUserMountCache
* @since 9.0.0
*/
public function getMountCache();
/**
* Get all root mountpoints
*
* @return \OCP\Files\Mount\IMountPoint[]
* @since 20.0.0
*/
public function getRootMounts(): array;
}
@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020, Morris Jobke <hey@morrisjobke.de>
*
* @author Morris Jobke <hey@morrisjobke.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Config;
use OCP\Files\Storage\IStorageFactory;
/**
* @since 20.0.0
*/
interface IRootMountProvider {
/**
* Get all root mountpoints of this provider
*
* @return \OCP\Files\Mount\IMountPoint[]
* @since 20.0.0
*/
public function getRootMounts(IStorageFactory $loader): array;
}
@@ -0,0 +1,152 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Julius Härtl <jus@bitgrid.net>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author szaimen <szaimen@e.mail.de>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\Files\Config;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\NotFoundException;
use OCP\IUser;
/**
* Cache mounts points per user in the cache so we can easily look them up
*
* @since 9.0.0
*/
interface IUserMountCache {
/**
* Register mounts for a user to the cache
*
* @param IUser $user
* @param IMountPoint[] $mounts
* @param array|null $mountProviderClasses
* @since 9.0.0
*/
public function registerMounts(IUser $user, array $mounts, array $mountProviderClasses = null);
/**
* Get all cached mounts for a user
*
* @param IUser $user
* @return ICachedMountInfo[]
* @since 9.0.0
*/
public function getMountsForUser(IUser $user);
/**
* Get all cached mounts by storage
*
* @param int $numericStorageId
* @param string|null $user limit the results to a single user @since 12.0.0
* @return ICachedMountInfo[]
* @since 9.0.0
*/
public function getMountsForStorageId($numericStorageId, $user = null);
/**
* Get all cached mounts by root
*
* @param int $rootFileId
* @return ICachedMountInfo[]
* @since 9.0.0
*/
public function getMountsForRootId($rootFileId);
/**
* Get all cached mounts that contain a file
*
* @param int $fileId
* @param string|null $user optionally restrict the results to a single user @since 12.0.0
* @return ICachedMountFileInfo[]
* @since 9.0.0
*/
public function getMountsForFileId($fileId, $user = null);
/**
* Remove all cached mounts for a user
*
* @param IUser $user
* @since 9.0.0
*/
public function removeUserMounts(IUser $user);
/**
* Remove all mounts for a user and storage
*
* @param $storageId
* @param string $userId
* @return mixed
* @since 9.0.0
*/
public function removeUserStorageMount($storageId, $userId);
/**
* Remove all cached mounts for a storage
*
* @param $storageId
* @return mixed
* @since 9.0.0
*/
public function remoteStorageMounts($storageId);
/**
* Get the used space for users
*
* Note that this only includes the space in their home directory,
* not any incoming shares or external storage.
*
* @param IUser[] $users
* @return int[] [$userId => $userSpace]
* @since 13.0.0
*/
public function getUsedSpaceForUsers(array $users);
/**
* Clear all entries from the in-memory cache
*
* @since 20.0.0
*/
public function clear(): void;
/**
* Get all cached mounts for a user
*
* @param IUser $user
* @param string $path
* @return ICachedMountInfo
* @throws NotFoundException
* @since 24.0.0
*/
public function getMountForPath(IUser $user, string $path): ICachedMountInfo;
/**
* Get all cached mounts for a user inside a path
*
* @param IUser $user
* @param string $path
* @return ICachedMountInfo[]
* @throws NotFoundException
* @since 24.0.0
*/
public function getMountsInPath(IUser $user, string $path): array;
}
@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Côme Chilliet <come.chilliet@nextcloud.com>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\Files;
/**
* Exception for lost connection with the
* @since 25.0.11
*/
class ConnectionLostException extends \RuntimeException {
}
+104
View File
@@ -0,0 +1,104 @@
<?php
/**
* @copyright Copyright (c) 2022 Côme Chilliet <come.chilliet@nextcloud.com>
*
* @author Arthur Schiwon <blizzz@owncloud.com>
* @author Bart Visscher <bartv@thisnet.nl>
* @author Jakob Sack <mail@jakobsack.de>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Klaas Freitag <freitag@owncloud.com>
* @author Markus Goetz <markus@woboq.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <icewind@owncloud.com>
* @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Vincent Petry <pvince81@owncloud.com>
* @author Côme Chilliet <come.chilliet@nextcloud.com>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\Files;
use OCP\Constants;
use OCP\Files\Mount\IMovableMount;
/**
* This class provides different helper functions related to WebDAV protocol
*
* @since 25.0.0
*/
class DavUtil {
/**
* Compute the fileId to use for dav responses
*
* @param int $id Id of the file returned by FileInfo::getId
* @since 25.0.0
*/
public static function getDavFileId(int $id): string {
$instanceId = \OC_Util::getInstanceId();
$id = sprintf('%08d', $id);
return $id . $instanceId;
}
/**
* Compute the format needed for returning permissions for dav
*
* @since 25.0.0
*/
public static function getDavPermissions(FileInfo $info): string {
$permissions = $info->getPermissions();
$p = '';
if ($info->isShared()) {
$p .= 'S';
}
if ($permissions & Constants::PERMISSION_SHARE) {
$p .= 'R';
}
if ($info->isMounted()) {
$p .= 'M';
}
if ($permissions & Constants::PERMISSION_READ) {
$p .= 'G';
}
if ($permissions & Constants::PERMISSION_DELETE) {
$p .= 'D';
}
if ($permissions & Constants::PERMISSION_UPDATE) {
$p .= 'NV'; // Renameable, Movable
}
// since we always add update permissions for the root of movable mounts
// we need to check the shared cache item directly to determine if it's writable
$storage = $info->getStorage();
if ($info->getInternalPath() === '' && $info->getMountPoint() instanceof IMovableMount) {
$rootEntry = $storage->getCache()->get('');
$isWritable = $rootEntry->getPermissions() & Constants::PERMISSION_UPDATE;
} else {
$isWritable = $permissions & Constants::PERMISSION_UPDATE;
}
if ($info->getType() === FileInfo::TYPE_FILE) {
if ($isWritable) {
$p .= 'W';
}
} else {
if ($permissions & Constants::PERMISSION_CREATE) {
$p .= 'CK';
}
}
return $p;
}
}
@@ -0,0 +1,31 @@
<?php
/**
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files;
/**
* Class EmptyFileNameException
*
* @since 9.2.0
*/
class EmptyFileNameException extends InvalidPathException {
}
@@ -0,0 +1,35 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
/**
* Exception for too large entity
* @since 6.0.0
*/
class EntityTooLargeException extends \Exception {
}
@@ -0,0 +1,84 @@
<?php
declare(strict_types=1);
/**
* @copyright 2022 Carl Schwan <carl@carlschwan.eu>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events;
use OCP\EventDispatcher\Event;
/**
* This event is triggered when a user tries to download a file
* directly.
*
* @since 25.0.0
*/
class BeforeDirectFileDownloadEvent extends Event {
private string $path;
private bool $successful = true;
private ?string $errorMessage = null;
/**
* @since 25.0.0
*/
public function __construct(string $path) {
parent::__construct();
$this->path = $path;
}
/**
* @since 25.0.0
*/
public function getPath(): string {
return $this->path;
}
/**
* @since 25.0.0
*/
public function isSuccessful(): bool {
return $this->successful;
}
/**
* Set if the event was successful
*
* @since 25.0.0
*/
public function setSuccessful(bool $successful): void {
$this->successful = $successful;
}
/**
* Get the error message, if any
* @since 25.0.0
*/
public function getErrorMessage(): ?string {
return $this->errorMessage;
}
/**
* @since 25.0.0
*/
public function setErrorMessage(string $errorMessage): void {
$this->errorMessage = $errorMessage;
}
}
@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
/**
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events;
use OCP\EventDispatcher\Event;
/**
* @since 18.0.0
*/
class BeforeFileScannedEvent extends Event {
/** @var string */
private $absolutePath;
/**
* @param string $absolutePath
*
* @since 18.0.0
*/
public function __construct(string $absolutePath) {
parent::__construct();
$this->absolutePath = $absolutePath;
}
/**
* @return string
* @since 18.0.0
*/
public function getAbsolutePath(): string {
return $this->absolutePath;
}
}
@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
/**
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events;
use OCP\EventDispatcher\Event;
/**
* @since 18.0.0
*/
class BeforeFolderScannedEvent extends Event {
/** @var string */
private $absolutePath;
/**
* @param string $absolutePath
*
* @since 18.0.0
*/
public function __construct(string $absolutePath) {
parent::__construct();
$this->absolutePath = $absolutePath;
}
/**
* @return string
* @since 18.0.0
*/
public function getAbsolutePath(): string {
return $this->absolutePath;
}
}
@@ -0,0 +1,91 @@
<?php
declare(strict_types=1);
/**
* @copyright 2022 Carl Schwan <carl@carlschwan.eu>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events;
use OCP\EventDispatcher\Event;
/**
* @since 25.0.0
*/
class BeforeZipCreatedEvent extends Event {
private string $directory;
private array $files;
private bool $successful = true;
private ?string $errorMessage = null;
/**
* @since 25.0.0
*/
public function __construct(string $directory, array $files) {
parent::__construct();
$this->directory = $directory;
$this->files = $files;
}
/**
* @since 25.0.0
*/
public function getDirectory(): string {
return $this->directory;
}
/**
* @since 25.0.0
*/
public function getFiles(): array {
return $this->files;
}
/**
* @since 25.0.0
*/
public function isSuccessful(): bool {
return $this->successful;
}
/**
* Set if the event was successful
*
* @since 25.0.0
*/
public function setSuccessful(bool $successful): void {
$this->successful = $successful;
}
/**
* Get the error message, if any
* @since 25.0.0
*/
public function getErrorMessage(): ?string {
return $this->errorMessage;
}
/**
* @since 25.0.0
*/
public function setErrorMessage(string $errorMessage): void {
$this->errorMessage = $errorMessage;
}
}
@@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
/**
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events;
use OCP\EventDispatcher\Event;
use OCP\Files\Storage\IStorage;
/**
* @since 18.0.0
*/
class FileCacheUpdated extends Event {
/** @var IStorage */
private $storage;
/** @var string */
private $path;
/**
* @param IStorage $storage
* @param string $path
* @since 18.0.0
*/
public function __construct(IStorage $storage,
string $path) {
parent::__construct();
$this->storage = $storage;
$this->path = $path;
}
/**
* @return IStorage
* @since 18.0.0
*/
public function getStorage(): IStorage {
return $this->storage;
}
/**
* @return string
* @since 18.0.0
*/
public function getPath(): string {
return $this->path;
}
}
@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
/**
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events;
use OCP\EventDispatcher\Event;
/**
* @since 18.0.0
*/
class FileScannedEvent extends Event {
/** @var string */
private $absolutePath;
/**
* @param string $absolutePath
*
* @since 18.0.0
*/
public function __construct(string $absolutePath) {
parent::__construct();
$this->absolutePath = $absolutePath;
}
/**
* @return string
* @since 18.0.0
*/
public function getAbsolutePath(): string {
return $this->absolutePath;
}
}
@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
/**
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events;
use OCP\EventDispatcher\Event;
/**
* @since 18.0.0
*/
class FolderScannedEvent extends Event {
/** @var string */
private $absolutePath;
/**
* @param string $absolutePath
*
* @since 18.0.0
*/
public function __construct(string $absolutePath) {
parent::__construct();
$this->absolutePath = $absolutePath;
}
/**
* @return string
* @since 18.0.0
*/
public function getAbsolutePath(): string {
return $this->absolutePath;
}
}
@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2022 Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events;
use OCP\EventDispatcher\Event;
use OCP\IUser;
/**
* Used to notify the filesystem setup manager that the available mounts for a user have changed
*
* @since 24.0.0
*/
class InvalidateMountCacheEvent extends Event {
private ?IUser $user;
/**
* @param IUser|null $user user
*
* @since 24.0.0
*/
public function __construct(?IUser $user) {
parent::__construct();
$this->user = $user;
}
/**
* @return IUser|null user
*
* @since 24.0.0
*/
public function getUser(): ?IUser {
return $this->user;
}
}
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events\Node;
use OCP\EventDispatcher\Event;
use OCP\Files\Node;
/**
* @since 20.0.0
*/
abstract class AbstractNodeEvent extends Event {
/** @var Node */
private $node;
/**
* @since 20.0.0
*/
public function __construct(Node $node) {
$this->node = $node;
}
/**
* @since 20.0.0
*/
public function getNode(): Node {
return $this->node;
}
}
@@ -0,0 +1,61 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events\Node;
use OCP\EventDispatcher\Event;
use OCP\Files\Node;
/**
* @since 20.0.0
*/
abstract class AbstractNodesEvent extends Event {
/** @var Node */
private $source;
/** @var Node */
private $target;
/**
* @since 20.0.0
*/
public function __construct(Node $source, Node $target) {
$this->source = $source;
$this->target = $target;
}
/**
* @since 20.0.0
*/
public function getSource(): Node {
return $this->source;
}
/**
* @since 20.0.0
*/
public function getTarget(): Node {
return $this->target;
}
}
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events\Node;
/**
* @since 20.0.0
*/
class BeforeNodeCopiedEvent extends AbstractNodesEvent {
}
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events\Node;
/**
* @since 20.0.0
*/
class BeforeNodeCreatedEvent extends AbstractNodeEvent {
}
@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events\Node;
use Exception;
use OCP\Files\Node;
/**
* @since 20.0.0
*/
class BeforeNodeDeletedEvent extends AbstractNodeEvent {
/**
* @since 20.0.0
*/
public function __construct(Node $node, private bool &$run) {
parent::__construct($node);
}
/**
* @since 28.0.0
* @return never
*/
public function abortOperation(\Throwable $ex = null) {
$this->stopPropagation();
$this->run = false;
if ($ex !== null) {
throw $ex;
} else {
throw new Exception('Operation aborted');
}
}
}
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events\Node;
/**
* @since 20.0.0
*/
class BeforeNodeReadEvent extends AbstractNodeEvent {
}
@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events\Node;
use Exception;
use OCP\Files\Node;
/**
* @since 20.0.0
*/
class BeforeNodeRenamedEvent extends AbstractNodesEvent {
/**
* @since 20.0.0
*/
public function __construct(Node $source, Node $target, private bool &$run) {
parent::__construct($source, $target);
}
/**
* @since 28.0.0
* @return never
*/
public function abortOperation(\Throwable $ex = null) {
$this->stopPropagation();
$this->run = false;
if ($ex !== null) {
throw $ex;
} else {
throw new Exception('Operation aborted');
}
}
}
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events\Node;
/**
* @since 20.0.0
*/
class BeforeNodeTouchedEvent extends AbstractNodeEvent {
}
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events\Node;
/**
* @since 20.0.0
*/
class BeforeNodeWrittenEvent extends AbstractNodeEvent {
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2022 Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events\Node;
use OCP\EventDispatcher\Event;
/**
* Event fired after the filesystem has been torn down
*
* @since 24.0.0
*/
class FilesystemTornDownEvent extends Event {
}
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events\Node;
/**
* @since 20.0.0
*/
class NodeCopiedEvent extends AbstractNodesEvent {
}
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events\Node;
/**
* @since 20.0.0
*/
class NodeCreatedEvent extends AbstractNodeEvent {
}
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events\Node;
/**
* @since 20.0.0
*/
class NodeDeletedEvent extends AbstractNodeEvent {
}
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events\Node;
/**
* @since 20.0.0
*/
class NodeRenamedEvent extends AbstractNodesEvent {
}
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events\Node;
/**
* @since 20.0.0
*/
class NodeTouchedEvent extends AbstractNodeEvent {
}
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events\Node;
/**
* @since 20.0.0
*/
class NodeWrittenEvent extends AbstractNodeEvent {
}
@@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
/**
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events;
use OCP\EventDispatcher\Event;
use OCP\Files\Storage\IStorage;
/**
* @since 18.0.0
*/
class NodeAddedToCache extends Event {
/** @var IStorage */
private $storage;
/** @var string */
private $path;
/**
* @param IStorage $storage
* @param string $path
* @since 18.0.0
*/
public function __construct(IStorage $storage,
string $path) {
parent::__construct();
$this->storage = $storage;
$this->path = $path;
}
/**
* @return IStorage
* @since 18.0.0
*/
public function getStorage(): IStorage {
return $this->storage;
}
/**
* @return string
* @since 18.0.0
*/
public function getPath(): string {
return $this->path;
}
}
@@ -0,0 +1,66 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events;
use OCP\EventDispatcher\Event;
use OCP\IUser;
/**
* @since 28.0.0
*/
class NodeAddedToFavorite extends Event {
/**
* @since 28.0.0
*/
public function __construct(
protected IUser $user,
protected int $fileId,
protected string $path,
) {
parent::__construct();
}
/**
* @since 28.0.0
*/
public function getUser(): IUser {
return $this->user;
}
/**
* @since 28.0.0
*/
public function getFileId(): int {
return $this->fileId;
}
/**
* @since 28.0.0
*/
public function getPath(): string {
return $this->path;
}
}
@@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
/**
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events;
use OCP\EventDispatcher\Event;
use OCP\Files\Storage\IStorage;
/**
* @since 18.0.0
*/
class NodeRemovedFromCache extends Event {
/** @var IStorage */
private $storage;
/** @var string */
private $path;
/**
* @param IStorage $storage
* @param string $path
* @since 18.0.0
*/
public function __construct(IStorage $storage,
string $path) {
parent::__construct();
$this->storage = $storage;
$this->path = $path;
}
/**
* @return IStorage
* @since 18.0.0
*/
public function getStorage(): IStorage {
return $this->storage;
}
/**
* @return string
* @since 18.0.0
*/
public function getPath(): string {
return $this->path;
}
}
@@ -0,0 +1,66 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Events;
use OCP\EventDispatcher\Event;
use OCP\IUser;
/**
* @since 28.0.0
*/
class NodeRemovedFromFavorite extends Event {
/**
* @since 28.0.0
*/
public function __construct(
protected IUser $user,
protected int $fileId,
protected string $path,
) {
parent::__construct();
}
/**
* @since 28.0.0
*/
public function getUser(): IUser {
return $this->user;
}
/**
* @since 28.0.0
*/
public function getFileId(): int {
return $this->fileId;
}
/**
* @since 28.0.0
*/
public function getPath(): string {
return $this->path;
}
}
+107
View File
@@ -0,0 +1,107 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Julius Härtl <jus@bitgrid.net>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
use OCP\Lock\LockedException;
/**
* Interface File
*
* @since 6.0.0
*/
interface File extends Node {
/**
* Get the content of the file as string
*
* @return string
* @throws NotPermittedException
* @throws GenericFileException
* @throws LockedException
* @since 6.0.0
*/
public function getContent();
/**
* Write to the file from string data
*
* @param string|resource $data
* @throws NotPermittedException
* @throws GenericFileException
* @throws LockedException
* @since 6.0.0
*/
public function putContent($data);
/**
* Get the mimetype of the file
*
* @return string
* @since 6.0.0
*/
public function getMimeType();
/**
* Open the file as stream, resulting resource can be operated as stream like the result from php's own fopen
*
* @param string $mode
* @return resource|false
* @throws NotPermittedException
* @throws LockedException
* @since 6.0.0
*/
public function fopen($mode);
/**
* Compute the hash of the file
* Type of hash is set with $type and can be anything supported by php's hash_file
*
* @param string $type
* @param bool $raw
* @return string
* @since 6.0.0
*/
public function hash($type, $raw = false);
/**
* Get the stored checksum for this file
*
* @return string
* @since 9.0.0
* @throws InvalidPathException
* @throws NotFoundException
*/
public function getChecksum();
/**
* Get the extension of this file
*
* @return string
* @since 15.0.0
*/
public function getExtension(): string;
}
+320
View File
@@ -0,0 +1,320 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Felix Heidecke <felix@heidecke.me>
* @author Joas Schilling <coding@schilljs.com>
* @author Julius Härtl <jus@bitgrid.net>
* @author Maxence Lange <maxence@artificial-owl.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\Files;
use OCP\Files\Storage\IStorage;
/**
* Interface FileInfo
*
* @since 7.0.0
*/
interface FileInfo {
/**
* @since 7.0.0
*/
public const TYPE_FILE = 'file';
/**
* @since 7.0.0
*/
public const TYPE_FOLDER = 'dir';
/**
* @const \OCP\Files\FileInfo::SPACE_NOT_COMPUTED Return value for a not computed space value
* @since 8.0.0
*/
public const SPACE_NOT_COMPUTED = -1;
/**
* @const \OCP\Files\FileInfo::SPACE_UNKNOWN Return value for unknown space value
* @since 8.0.0
*/
public const SPACE_UNKNOWN = -2;
/**
* @const \OCP\Files\FileInfo::SPACE_UNLIMITED Return value for unlimited space
* @since 8.0.0
*/
public const SPACE_UNLIMITED = -3;
/**
* @since 9.1.0
*/
public const MIMETYPE_FOLDER = 'httpd/unix-directory';
/**
* @const \OCP\Files\FileInfo::BLACKLIST_FILES_REGEX Return regular expression to test filenames against (blacklisting)
* @since 12.0.0
*/
public const BLACKLIST_FILES_REGEX = '\.(part|filepart)$';
/**
* Get the Etag of the file or folder
*
* @return string
* @since 7.0.0
*/
public function getEtag();
/**
* Get the size in bytes for the file or folder
*
* @param bool $includeMounts whether or not to include the size of any sub mounts, since 16.0.0
* @return int|float
* @since 7.0.0
*/
public function getSize($includeMounts = true);
/**
* Get the last modified date as timestamp for the file or folder
*
* @return int
* @since 7.0.0
*/
public function getMtime();
/**
* Get the name of the file or folder
*
* @return string
* @since 7.0.0
*/
public function getName();
/**
* Get the path relative to the storage
*
* @return string
* @since 7.0.0
*/
public function getInternalPath();
/**
* Get the absolute path
*
* @return string
* @since 7.0.0
*/
public function getPath();
/**
* Get the full mimetype of the file or folder i.e. 'image/png'
*
* @return string
* @since 7.0.0
*/
public function getMimetype();
/**
* Get the first part of the mimetype of the file or folder i.e. 'image'
*
* @return string
* @since 7.0.0
*/
public function getMimePart();
/**
* Get the storage the file or folder is storage on
*
* @return IStorage
* @since 7.0.0
*/
public function getStorage();
/**
* Get the file id of the file or folder
*
* @return int|null
* @since 7.0.0
*/
public function getId();
/**
* Check whether the file is encrypted
*
* @return bool
* @since 7.0.0
*/
public function isEncrypted();
/**
* Get the permissions of the file or folder as bitmasked combination of the following constants
* \OCP\Constants::PERMISSION_CREATE
* \OCP\Constants::PERMISSION_READ
* \OCP\Constants::PERMISSION_UPDATE
* \OCP\Constants::PERMISSION_DELETE
* \OCP\Constants::PERMISSION_SHARE
* \OCP\Constants::PERMISSION_ALL
*
* @return int
* @since 7.0.0 - namespace of constants has changed in 8.0.0
*/
public function getPermissions();
/**
* Check whether this is a file or a folder
*
* @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER
* @since 7.0.0
*/
public function getType();
/**
* Check if the file or folder is readable
*
* @return bool
* @since 7.0.0
*/
public function isReadable();
/**
* Check if a file is writable
*
* @return bool
* @since 7.0.0
*/
public function isUpdateable();
/**
* Check whether new files or folders can be created inside this folder
*
* @return bool
* @since 8.0.0
*/
public function isCreatable();
/**
* Check if a file or folder can be deleted
*
* @return bool
* @since 7.0.0
*/
public function isDeletable();
/**
* Check if a file or folder can be shared
*
* @return bool
* @since 7.0.0
*/
public function isShareable();
/**
* Check if a file or folder is shared
*
* @return bool
* @since 7.0.0
*/
public function isShared();
/**
* Check if a file or folder is mounted
*
* @return bool
* @since 7.0.0
*/
public function isMounted();
/**
* Get the mountpoint the file belongs to
*
* @return \OCP\Files\Mount\IMountPoint
* @since 8.0.0
*/
public function getMountPoint();
/**
* Get the owner of the file
*
* @return ?\OCP\IUser
* @since 9.0.0
*/
public function getOwner();
/**
* Get the stored checksum(s) for this file
*
* Checksums are stored in the format TYPE:CHECKSUM, here may be multiple checksums separated by a single space
* e.g. MD5:d3b07384d113edec49eaa6238ad5ff00 SHA1:f1d2d2f924e986ac86fdf7b36c94bcdf32beec15
*
* @return string
* @since 9.0.0
*/
public function getChecksum();
/**
* Get the extension of the file
*
* @return string
* @since 15.0.0
*/
public function getExtension(): string;
/**
* Get the creation date as unix timestamp
*
* If the creation time is not known, 0 will be returned
*
* creation time is not set automatically by the server and is generally only available
* for files uploaded by the sync clients
*
* @return int
* @since 18.0.0
*/
public function getCreationTime(): int;
/**
* Get the upload date as unix timestamp
*
* If the upload time is not known, 0 will be returned
*
* Upload time will be set automatically by the server for files uploaded over DAV
* files created by Nextcloud apps generally do not have an the upload time set
*
* @return int
* @since 18.0.0
*/
public function getUploadTime(): int;
/**
* Get the fileid or the parent folder
* or -1 if this item has no parent folder (because it is the root)
*
* @return int
* @since 28.0.0
*/
public function getParentId(): int;
/**
* Get the metadata, if available
*
* @return array<string, int|string|bool|float|string[]|int[]>
* @since 28.0.0
*/
public function getMetadata(): array;
}
@@ -0,0 +1,35 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
/**
* Class FileNameTooLongException
*
* @since 8.1.0
*/
class FileNameTooLongException extends InvalidPathException {
}
+199
View File
@@ -0,0 +1,199 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Vincent Petry <vincent@nextcloud.com>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
use OCP\Files\Search\ISearchQuery;
/**
* @since 6.0.0
*/
interface Folder extends Node {
/**
* Get the full path of an item in the folder within owncloud's filesystem
*
* @param string $path relative path of an item in the folder
* @return string
* @throws \OCP\Files\NotPermittedException
* @since 6.0.0
*/
public function getFullPath($path);
/**
* Get the path of an item in the folder relative to the folder
*
* @param string $path absolute path of an item in the folder
* @throws \OCP\Files\NotFoundException
* @return string|null
* @since 6.0.0
*/
public function getRelativePath($path);
/**
* check if a node is a (grand-)child of the folder
*
* @param \OCP\Files\Node $node
* @return bool
* @since 6.0.0
*/
public function isSubNode($node);
/**
* get the content of this directory
*
* @throws \OCP\Files\NotFoundException
* @return \OCP\Files\Node[]
* @since 6.0.0
*/
public function getDirectoryListing();
/**
* Get the node at $path
*
* @param string $path relative path of the file or folder
* @return \OCP\Files\Node
* @throws \OCP\Files\NotFoundException
* @since 6.0.0
*/
public function get($path);
/**
* Check if a file or folder exists in the folder
*
* @param string $path relative path of the file or folder
* @return bool
* @since 6.0.0
*/
public function nodeExists($path);
/**
* Create a new folder
*
* @param string $path relative path of the new folder
* @return \OCP\Files\Folder
* @throws \OCP\Files\NotPermittedException
* @since 6.0.0
*/
public function newFolder($path);
/**
* Create a new file
*
* @param string $path relative path of the new file
* @param string|resource|null $content content for the new file, since 19.0.0
* @return \OCP\Files\File
* @throws \OCP\Files\NotPermittedException
* @since 6.0.0
*/
public function newFile($path, $content = null);
/**
* search for files with the name matching $query
*
* @param string|ISearchQuery $query
* @return \OCP\Files\Node[]
* @since 6.0.0
*/
public function search($query);
/**
* search for files by mimetype
* $mimetype can either be a full mimetype (image/png) or a wildcard mimetype (image)
*
* @param string $mimetype
* @return \OCP\Files\Node[]
* @since 6.0.0
*/
public function searchByMime($mimetype);
/**
* search for files by tag
*
* @param string|int $tag tag name or tag id
* @param string $userId owner of the tags
* @return \OCP\Files\Node[]
* @since 8.0.0
*/
public function searchByTag($tag, $userId);
/**
* search for files by system tag
*
* @param string|int $tag tag name
* @param string $userId user id to ensure access on returned nodes
* @return \OCP\Files\Node[]
* @since 28.0.0
*/
public function searchBySystemTag(string $tagName, string $userId, int $limit = 0, int $offset = 0);
/**
* get a file or folder inside the folder by it's internal id
*
* This method could return multiple entries. For example once the file/folder
* is shared or mounted (files_external) to the user multiple times.
*
* @param int $id
* @return \OCP\Files\Node[]
* @since 6.0.0
*/
public function getById($id);
/**
* Get the amount of free space inside the folder
*
* @return int
* @since 6.0.0
*/
public function getFreeSpace();
/**
* Check if new files or folders can be created within the folder
*
* @return bool
* @since 6.0.0
*/
public function isCreatable();
/**
* Add a suffix to the name in case the file exists
*
* @param string $name
* @return string
* @throws NotPermittedException
* @since 8.1.0
*/
public function getNonExistingName($name);
/**
* @param int $limit
* @param int $offset
* @return \OCP\Files\Node[]
* @since 9.1.0
*/
public function getRecent($limit, $offset = 0);
}
@@ -0,0 +1,56 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Joas Schilling <coding@schilljs.com>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
/**
* Class ForbiddenException
*
* @since 9.0.0
*/
class ForbiddenException extends \Exception {
/** @var bool */
private $retry;
/**
* @param string $message
* @param bool $retry
* @param \Exception|null $previous previous exception for cascading
* @since 9.0.0
*/
public function __construct($message, $retry, \Exception $previous = null) {
parent::__construct($message, 0, $previous);
$this->retry = $retry;
}
/**
* @return bool
* @since 9.0.0
*/
public function getRetry() {
return (bool) $this->retry;
}
}
@@ -0,0 +1,31 @@
<?php
/**
* @copyright 2018, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files;
/**
* Class GenericFileException
*
* @since 14.0.0
*/
class GenericFileException extends \Exception {
}
@@ -0,0 +1,34 @@
<?php
/**
* @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files;
use OCP\Files\SimpleFS\ISimpleRoot;
/**
* Interface IAppData
*
* @since 11.0.0
*/
interface IAppData extends ISimpleRoot {
}
@@ -0,0 +1,45 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Joas Schilling <coding@schilljs.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
use OCP\Files\Storage\IStorage;
use OCP\IUser;
/**
* Interface IHomeStorage
*
* @since 7.0.0
*/
interface IHomeStorage extends IStorage {
/**
* Get the user for this home storage
*
* @return IUser
* @since 28.0.0
*/
public function getUser(): IUser;
}
@@ -0,0 +1,91 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Joas Schilling <coding@schilljs.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
/**
* Interface IMimeTypeDetector
* @since 8.2.0
*
* Interface to handle mimetypes (detection and icon retrieval)
**/
interface IMimeTypeDetector {
/**
* detect mimetype only based on filename, content of file is not used
* @param string $path
* @return string
* @since 8.2.0
*/
public function detectPath($path);
/**
* detect mimetype only based on the content of file
* @param string $path
* @return string
* @since 18.0.0
*/
public function detectContent(string $path): string;
/**
* detect mimetype based on both filename and content
*
* @param string $path
* @return string
* @since 8.2.0
*/
public function detect($path);
/**
* Get a secure mimetype that won't expose potential XSS.
*
* @param string $mimeType
* @return string
* @since 8.2.0
*/
public function getSecureMimeType($mimeType);
/**
* detect mimetype based on the content of a string
*
* @param string $data
* @return string
* @since 8.2.0
*/
public function detectString($data);
/**
* Get path to the icon of a file type
* @param string $mimeType the MIME type
* @return string the url
* @since 8.2.0
*/
public function mimeTypeIcon($mimeType);
/**
* @return string[]
* @since 28.0.0
*/
public function getAllAliases(): array;
}
@@ -0,0 +1,64 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Robin McCorkell <robin@mccorkell.me.uk>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\Files;
/**
* Interface IMimeTypeLoader
* @since 8.2.0
*
* Interface to load mimetypes
**/
interface IMimeTypeLoader {
/**
* Get a mimetype from its ID
*
* @param int $id
* @return string|null
* @since 8.2.0
*/
public function getMimetypeById($id);
/**
* Get a mimetype ID, adding the mimetype to the DB if it does not exist
*
* @param string $mimetype
* @return int
* @since 8.2.0
*/
public function getId($mimetype);
/**
* Test if a mimetype exists in the database
*
* @param string $mimetype
* @return bool
* @since 8.2.0
*/
public function exists($mimetype);
/**
* Clear all loaded mimetypes, allow for re-loading
*
* @since 8.2.0
*/
public function reset();
}
@@ -0,0 +1,83 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Julius Härtl <jus@bitgrid.net>
* @author Morris Jobke <hey@morrisjobke.de>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\Files;
use OC\Hooks\Emitter;
use OC\User\NoUserException;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\Node as INode;
/**
* Interface IRootFolder
*
* @since 8.0.0
*/
interface IRootFolder extends Folder, Emitter {
/**
* Returns a view to user's files folder
*
* @param string $userId user ID
* @return Folder
* @throws NoUserException
* @throws NotPermittedException
*
* @since 8.2.0
*/
public function getUserFolder($userId);
/**
* Get a file or folder by fileid, inside a parent path
*
* @param int $id
* @param string $path
* @return Node[]
*
* @since 24.0.0
*/
public function getByIdInPath(int $id, string $path);
/**
* @return IMountPoint[]
*
* @since 28.0.0
*/
public function getMountsIn(string $mountPoint): array;
/**
* Create a `Node` for a file or folder from the cache entry and mountpoint
*
* @param ICacheEntry $cacheEntry
* @param IMountPoint $mountPoint
* @return Node
* @since 28.0.0
*/
public function getNodeFromCacheEntryAndMount(ICacheEntry $cacheEntry, IMountPoint $mountPoint): INode;
/**
* @since 28.0.0
*/
public function getMount(string $mountPoint): IMountPoint;
}
@@ -0,0 +1,34 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
/**
* Exception for invalid path
* @since 8.1.0
*/
class InvalidCharacterInPathException extends InvalidPathException {
}
@@ -0,0 +1,35 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
/**
* Exception for invalid content
* @since 6.0.0
*/
class InvalidContentException extends \Exception {
}
@@ -0,0 +1,31 @@
<?php
/**
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files;
/**
* Class InvalidDirectoryException
*
* @since 9.2.0
*/
class InvalidDirectoryException extends InvalidPathException {
}
@@ -0,0 +1,35 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
/**
* Exception for invalid path
* @since 6.0.0
*/
class InvalidPathException extends \Exception {
}
@@ -0,0 +1,162 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2022 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Lock;
/**
* @since 24.0.0
*/
interface ILock {
/**
* User owned manual lock
*
* This lock type is initiated by a user manually through the web UI or clients
* and will limit editing capabilities on the file to the lock owning user.
*
* @since 24.0.0
*/
public const TYPE_USER = 0;
/**
* App owned lock
*
* This lock type is created by collaborative apps like Text or Office to avoid
* outside changes through WevDAV or other apps.
* @since 24.0.0
*
*/
public const TYPE_APP = 1;
/**
* Token owned lock
*
* This lock type will bind the ownership to the provided lock token. Any request
* that aims to modify the file will be required to sent the token, the user
* itself is not able to write to files without the token. This will allow
* to limit the locking to an individual client.
*
* @since 24.0.0
*/
public const TYPE_TOKEN = 2;
/**
* WebDAV Lock scope exclusive
*
* @since 24.0.0
*/
public const LOCK_EXCLUSIVE = 1;
/**
* WebDAV Lock scope shared
*
* @since 24.0.0
*/
public const LOCK_SHARED = 2;
/**
* Lock only the resource the lock is applied to
*
* @since 24.0.0
*/
public const LOCK_DEPTH_ZERO = 0;
/**
* Lock app resources under the locked one with infinite depth
*
* @since 24.0.0
*/
public const LOCK_DEPTH_INFINITE = -1;
/**
* Type of the lock
*
* @psalm-return ILock::TYPE_*
* @since 24.0.0
*/
public function getType(): int;
/**
* Owner that holds the lock
*
* Depending on the lock type this is:
* - ILock::TYPE_USER: A user id
* - ILock::TYPE_APP: An app id
* - ILock::TYPE_TOKEN: A user id
*
* @since 24.0.0
*/
public function getOwner(): string;
/**
* File id that the lock is holding
*
* @since 24.0.0
*/
public function getFileId(): int;
/**
* Timeout of the lock in seconds starting from the created at time
*
* @since 24.0.0
*/
public function getTimeout(): int;
/**
* Unix timestamp of the lock creation time
*
* @since 24.0.0
*/
public function getCreatedAt(): int;
/**
* Token string as a unique identifier for the lock, usually a UUID
*
* @since 24.0.0
*/
public function getToken(): string;
/**
* Lock depth to apply the lock to child resources
*
* @since 24.0.0
*/
public function getDepth(): int;
/**
* WebDAV lock scope
*
* @since 24.0.0
* @psalm-return ILock::LOCK_EXCLUSIVE|ILock::LOCK_SHARED
*/
public function getScope(): int;
/**
* String representation of the lock to identify it through logging
*
* @since 24.0.0
*/
public function __toString(): string;
}
@@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2022 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Lock;
use OCP\PreConditionNotMetException;
/**
* Manage app integrations with files_lock with collaborative editors
*
* The OCP parts are mainly for exposing the ability to lock/unlock for apps and
* to give the files_lock app a way to register and then be triggered by the apps
* while the actual locking implementation is kept in the LockProvider and DAV
* plugin from files_lock app.
*
* @since 24.0.0
*/
interface ILockManager extends ILockProvider {
/**
* @throws PreConditionNotMetException if there is already a lock provider registered
* @since 24.0.0
*/
public function registerLockProvider(ILockProvider $lockProvider): void;
/**
* @return bool
* @since 24.0.0
*/
public function isLockProviderAvailable(): bool;
/**
* Run within the scope of a given lock condition
*
* The callback will also be executed if no lock provider is present
*
* @since 24.0.0
*/
public function runInScope(LockContext $lock, callable $callback): void;
/**
* @throws NoLockProviderException if there is no lock provider available
* @since 24.0.0
*/
public function getLockInScope(): ?LockContext;
}
@@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2022 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Lock;
use OCP\PreConditionNotMetException;
/**
* @since 24.0.0
*/
interface ILockProvider {
/**
* @throws PreConditionNotMetException
* @throws NoLockProviderException
* @psalm-return list<ILock>
* @since 24.0.0
*/
public function getLocks(int $fileId): array;
/**
* @throws PreConditionNotMetException
* @throws OwnerLockedException
* @throws NoLockProviderException
* @since 24.0.0
*/
public function lock(LockContext $lockInfo): ILock;
/**
* @throws PreConditionNotMetException
* @throws NoLockProviderException
* @since 24.0.0
*/
public function unlock(LockContext $lockInfo): void;
}
@@ -0,0 +1,99 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2022 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Lock;
use OCP\Files\Node;
/**
* Structure to identify a specific lock context to request or
* describe a lock with the affected node and ownership information
*
* This is used to match a lock/unlock request or file operation to existing locks
*
* @since 24.0.0
*/
final class LockContext {
private Node $node;
private int $type;
private string $owner;
/**
* @param Node $node Node that is owned by the lock
* @param int $type Type of the lock owner
* @param string $owner Unique identifier for the lock owner based on the type
* @since 24.0.0
*/
public function __construct(
Node $node,
int $type,
string $owner
) {
$this->node = $node;
$this->type = $type;
$this->owner = $owner;
}
/**
* @since 24.0.0
*/
public function getNode(): Node {
return $this->node;
}
/**
* @return int
* @since 24.0.0
*/
public function getType(): int {
return $this->type;
}
/**
* @return string user id / app id / lock token depending on the type
* @since 24.0.0
*/
public function getOwner(): string {
return $this->owner;
}
/**
* @since 24.0.0
*/
public function __toString(): string {
$typeString = 'unknown';
if ($this->type === ILock::TYPE_USER) {
$typeString = 'ILock::TYPE_USER';
}
if ($this->type === ILock::TYPE_APP) {
$typeString = 'ILock::TYPE_APP';
}
if ($this->type === ILock::TYPE_TOKEN) {
$typeString = 'ILock::TYPE_TOKEN';
}
return "$typeString $this->owner " . $this->getNode()->getId();
}
}
@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2022 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Lock;
use Exception;
/**
* @since 24.0.0
*/
class NoLockProviderException extends Exception {
}
@@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2022 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Lock;
use OCP\Lock\LockedException;
/**
* @since 24.0.0
*/
class OwnerLockedException extends LockedException {
private ILock $lock;
/**
* @since 24.0.0
*/
public function __construct(ILock $lock) {
$this->lock = $lock;
$path = '';
$readablePath = '';
parent::__construct($path, null, $lock->getOwner(), $readablePath);
}
/**
* @since 24.0.0
*/
public function getLock(): ILock {
return $this->lock;
}
}
@@ -0,0 +1,59 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Owen Winkler <a_github@midnightcircus.com>
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
/**
* Exception for a file that is locked
* @since 7.0.0
*/
class LockNotAcquiredException extends \Exception {
/** @var string $path The path that could not be locked */
public $path;
/** @var integer $lockType The type of the lock that was attempted */
public $lockType;
/**
* @since 7.0.0
*/
public function __construct($path, $lockType, $code = 0, \Exception $previous = null) {
$message = \OC::$server->getL10N('core')->t('Could not obtain lock type %d on "%s".', [$lockType, $path]);
parent::__construct($message, $code, $previous);
}
/**
* custom string representation of object
*
* @return string
* @since 7.0.0
*/
public function __toString() {
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
}
}
@@ -0,0 +1,121 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\Files\Mount;
use OCP\Files\Config\ICachedMountInfo;
/**
* Interface IMountManager
*
* Manages all mounted storages in the system
* @since 8.2.0
*/
interface IMountManager {
/**
* Add a new mount
*
* @param IMountPoint $mount
* @since 8.2.0
*/
public function addMount(IMountPoint $mount);
/**
* Remove a mount
*
* @param string $mountPoint
* @since 8.2.0
*/
public function removeMount(string $mountPoint);
/**
* Change the location of a mount
*
* @param string $mountPoint
* @param string $target
* @since 8.2.0
*/
public function moveMount(string $mountPoint, string $target);
/**
* Find the mount for $path
*
* @param string $path
* @return IMountPoint
* @since 8.2.0
*/
public function find(string $path): ?IMountPoint;
/**
* Find all mounts in $path
*
* @param string $path
* @return IMountPoint[]
* @since 8.2.0
*/
public function findIn(string $path): array;
/**
* Remove all registered mounts
*
* @since 8.2.0
*/
public function clear();
/**
* Find mounts by storage id
*
* @param string $id
* @return IMountPoint[]
* @since 8.2.0
*/
public function findByStorageId(string $id): array;
/**
* @return IMountPoint[]
* @since 8.2.0
*/
public function getAll(): array;
/**
* Find mounts by numeric storage id
*
* @param int $id
* @return IMountPoint[]
* @since 8.2.0
*/
public function findByNumericId(int $id): array;
/**
* Return the mount matching a cached mount info (or mount file info)
*
* @param ICachedMountInfo $info
*
* @return IMountPoint|null
* @since 28.0.0
*/
public function getMountFromMountInfo(ICachedMountInfo $info): ?IMountPoint;
}
@@ -0,0 +1,138 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author szaimen <szaimen@e.mail.de>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\Files\Mount;
/**
* A storage mounted to folder on the filesystem
* @since 8.0.0
*/
interface IMountPoint {
/**
* get complete path to the mount point
*
* @return string
* @since 8.0.0
*/
public function getMountPoint();
/**
* Set the mountpoint
*
* @param string $mountPoint new mount point
* @since 8.0.0
*/
public function setMountPoint($mountPoint);
/**
* Get the storage that is mounted
*
* @return \OCP\Files\Storage\IStorage|null
* @since 8.0.0
*/
public function getStorage();
/**
* Get the id of the storages
*
* @return string|null
* @since 8.0.0
*/
public function getStorageId();
/**
* Get the id of the storages
*
* @return int|null
* @since 9.1.0
*/
public function getNumericStorageId();
/**
* Get the path relative to the mountpoint
*
* @param string $path absolute path to a file or folder
* @return string
* @since 8.0.0
*/
public function getInternalPath($path);
/**
* Apply a storage wrapper to the mounted storage
*
* @param callable $wrapper
* @since 8.0.0
*/
public function wrapStorage($wrapper);
/**
* Get a mount option
*
* @param string $name Name of the mount option to get
* @param mixed $default Default value for the mount option
* @return mixed
* @since 8.0.0
*/
public function getOption($name, $default);
/**
* Get all options for the mount
*
* @return array
* @since 8.1.0
*/
public function getOptions();
/**
* Get the file id of the root of the storage
*
* @return int
* @since 9.1.0
*/
public function getStorageRootId();
/**
* Get the id of the configured mount
*
* @return int|null mount id or null if not applicable
* @since 9.1.0
*/
public function getMountId();
/**
* Get the type of mount point, used to distinguish things like shares and external storage
* in the web interface
*
* @return string
* @since 12.0.0
*/
public function getMountType();
/**
* Get the class of the mount provider that this mount originates from
*
* @return string
* @since 24.0.0
*/
public function getMountProvider(): string;
}
@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Mount;
/**
* Denotes that the mount point can be (re)moved by the user
*
* @since 28.0.0
*/
interface IMovableMount {
/**
* Move the mount point to $target
*
* @param string $target the target mount point
* @return bool
* @since 28.0.0
*/
public function moveMount($target);
/**
* Remove the mount points
*
* @return bool
* @since 28.0.0
*/
public function removeMount();
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2022 Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Mount;
/**
* Mark a mountpoint as containing system data, meaning that the data is not user specific
*
* Example use case is signaling to the encryption wrapper that system-wide keys should be used for a mountpoint
*
* @since 25.0.0
*/
interface ISystemMountPoint extends IMountPoint {
}
+289
View File
@@ -0,0 +1,289 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @author Joas Schilling <coding@schilljs.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Julius Härtl <jus@bitgrid.net>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
use OCP\Files\Storage\IStorage;
use OCP\Lock\LockedException;
/**
* Interface Node
*
* @since 6.0.0 - extends FileInfo was added in 8.0.0
*/
interface Node extends FileInfo {
/**
* Move the file or folder to a new location
*
* @param string $targetPath the absolute target path
* @return Node
* @throws NotFoundException
* @throws NotPermittedException if move not allowed or failed
* @throws LockedException
* @throws InvalidPathException
* @since 6.0.0
*/
public function move($targetPath);
/**
* Delete the file or folder
*
* @return void
* @throws NotPermittedException
* @throws InvalidPathException
* @throws NotFoundException
* @since 6.0.0
*/
public function delete();
/**
* Copy the file or folder to a new location
*
* @param string $targetPath the absolute target path
* @return Node
* @since 6.0.0
*/
public function copy($targetPath);
/**
* Change the modified date of the file or folder
* If $mtime is omitted the current time will be used
*
* @param int $mtime (optional) modified date as unix timestamp
* @throws InvalidPathException
* @throws NotFoundException
* @throws NotPermittedException
* @return void
* @since 6.0.0
*/
public function touch($mtime = null);
/**
* Get the storage backend the file or folder is stored on
*
* @return IStorage
* @throws NotFoundException
* @since 6.0.0
*/
public function getStorage();
/**
* Get the full path of the file or folder
*
* @return string
* @since 6.0.0
*/
public function getPath();
/**
* Get the path of the file or folder relative to the mountpoint of it's storage
*
* @return string
* @since 6.0.0
*/
public function getInternalPath();
/**
* Get the internal file id for the file or folder
*
* @return int
* @throws InvalidPathException
* @throws NotFoundException
* @since 6.0.0
*/
public function getId();
/**
* Get metadata of the file or folder
* The returned array contains the following values:
* - mtime
* - size
*
* @return array
* @since 6.0.0
*/
public function stat();
/**
* Get the modified date of the file or folder as unix timestamp
*
* @return int
* @throws InvalidPathException
* @throws NotFoundException
* @since 6.0.0
*/
public function getMTime();
/**
* Get the size of the file or folder in bytes
*
* @param bool $includeMounts
* @return int|float
* @throws InvalidPathException
* @throws NotFoundException
* @since 6.0.0
*/
public function getSize($includeMounts = true);
/**
* Get the Etag of the file or folder
* The Etag is an string id used to detect changes to a file or folder,
* every time the file or folder is changed the Etag will change to
*
* @return string
* @throws InvalidPathException
* @throws NotFoundException
* @since 6.0.0
*/
public function getEtag();
/**
* Get the permissions of the file or folder as a combination of one or more of the following constants:
* - \OCP\Constants::PERMISSION_READ
* - \OCP\Constants::PERMISSION_UPDATE
* - \OCP\Constants::PERMISSION_CREATE
* - \OCP\Constants::PERMISSION_DELETE
* - \OCP\Constants::PERMISSION_SHARE
*
* @return int
* @throws InvalidPathException
* @throws NotFoundException
* @since 6.0.0 - namespace of constants has changed in 8.0.0
*/
public function getPermissions();
/**
* Check if the file or folder is readable
*
* @return bool
* @throws InvalidPathException
* @throws NotFoundException
* @since 6.0.0
*/
public function isReadable();
/**
* Check if the file or folder is writable
*
* @return bool
* @throws InvalidPathException
* @throws NotFoundException
* @since 6.0.0
*/
public function isUpdateable();
/**
* Check if the file or folder is deletable
*
* @return bool
* @throws InvalidPathException
* @throws NotFoundException
* @since 6.0.0
*/
public function isDeletable();
/**
* Check if the file or folder is shareable
*
* @return bool
* @throws InvalidPathException
* @throws NotFoundException
* @since 6.0.0
*/
public function isShareable();
/**
* Get the parent folder of the file or folder
*
* @return Folder
* @since 6.0.0
*/
public function getParent();
/**
* Get the filename of the file or folder
*
* @return string
* @since 6.0.0
*/
public function getName();
/**
* Acquire a lock on this file or folder.
*
* A shared (read) lock will prevent any exclusive (write) locks from being created but any number of shared locks
* can be active at the same time.
* An exclusive lock will prevent any other lock from being created (both shared and exclusive).
*
* A locked exception will be thrown if any conflicting lock already exists
*
* Note that this uses mandatory locking, if you acquire an exclusive lock on a file it will block *all*
* other operations for that file, even within the same php process.
*
* Acquiring any lock on a file will also create a shared lock on all parent folders of that file.
*
* Note that in most cases you won't need to manually manage the locks for any files you're working with,
* any filesystem operation will automatically acquire the relevant locks for that operation.
*
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @throws LockedException
* @since 9.1.0
*/
public function lock($type);
/**
* Check the type of an existing lock.
*
* A shared lock can be changed to an exclusive lock is there is exactly one shared lock on the file,
* an exclusive lock can always be changed to a shared lock since there can only be one exclusive lock int he first place.
*
* A locked exception will be thrown when these preconditions are not met.
* Note that this is also the case if no existing lock exists for the file.
*
* @param int $targetType \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @throws LockedException
* @since 9.1.0
*/
public function changeLock($targetType);
/**
* Release an existing lock.
*
* This will also free up the shared locks on any parent folder that were automatically acquired when locking the file.
*
* Note that this method will not give any sort of error when trying to free a lock that doesn't exist.
*
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @throws LockedException
* @since 9.1.0
*/
public function unlock($type);
}
@@ -0,0 +1,35 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
/**
* Exception for not enough space
* @since 6.0.0
*/
class NotEnoughSpaceException extends \Exception {
}
@@ -0,0 +1,35 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
/**
* Exception for not found entity
* @since 6.0.0
*/
class NotFoundException extends \Exception {
}
@@ -0,0 +1,35 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
/**
* Exception for not permitted action
* @since 6.0.0
*/
class NotPermittedException extends \Exception {
}
@@ -0,0 +1,56 @@
<?php
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Notify;
/**
* Represents a detected change in the storage
*
* @since 12.0.0
*/
interface IChange {
public const ADDED = 1;
public const REMOVED = 2;
public const MODIFIED = 3;
public const RENAMED = 4;
/**
* Get the type of the change
*
* @return int IChange::ADDED, IChange::REMOVED, IChange::MODIFIED or IChange::RENAMED
*
* @since 12.0.0
*/
public function getType();
/**
* Get the path of the file that was changed relative to the root of the storage
*
* Note, for rename changes this path is the old path for the file
*
* @return mixed
*
* @since 12.0.0
*/
public function getPath();
}
@@ -0,0 +1,63 @@
<?php
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
* @author Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Notify;
/**
* Provides access to detected changes in the storage by either actively listening
* or getting the list of changes that happened in the background
*
* @since 12.0.0
*/
interface INotifyHandler {
/**
* Start listening for update notifications
*
* The provided callback will be called for every incoming notification with the following parameters
* - IChange|IRenameChange $change
*
* Note that this call is blocking and will not exit on it's own, to stop listening for notifications return `false` from the callback
*
* @param callable $callback
*
* @since 12.0.0
*/
public function listen(callable $callback);
/**
* Get all changes detected since the start of the notify process or the last call to getChanges
*
* @return IChange[]
*
* @since 12.0.0
*/
public function getChanges();
/**
* Stop listening for changes
*
* Note that any pending changes will be discarded
*
* @since 12.0.0
*/
public function stop();
}
@@ -0,0 +1,39 @@
<?php
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
* @author Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Notify;
/**
* Represents a detected rename change
*
* @since 12.0.0
*/
interface IRenameChange extends IChange {
/**
* Get the new path of the renamed file relative to the storage root
*
* @return string
*
* @since 12.0.0
*/
public function getTargetPath();
}
@@ -0,0 +1,83 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\Files\ObjectStore;
use OCP\Files\NotFoundException;
/**
* Interface IObjectStore
*
* @since 7.0.0
*/
interface IObjectStore {
/**
* @return string the container or bucket name where objects are stored
* @since 7.0.0
*/
public function getStorageId();
/**
* @param string $urn the unified resource name used to identify the object
* @return resource stream with the read data
* @throws \Exception when something goes wrong, message will be logged
* @throws NotFoundException if file does not exist
* @since 7.0.0
*/
public function readObject($urn);
/**
* @param string $urn the unified resource name used to identify the object
* @param resource $stream stream with the data to write
* @param string|null $mimetype the mimetype to set for the remove object @since 22.0.0
* @throws \Exception when something goes wrong, message will be logged
* @since 7.0.0
*/
public function writeObject($urn, $stream, string $mimetype = null);
/**
* @param string $urn the unified resource name used to identify the object
* @return void
* @throws \Exception when something goes wrong, message will be logged
* @since 7.0.0
*/
public function deleteObject($urn);
/**
* Check if an object exists in the object store
*
* @param string $urn
* @return bool
* @since 16.0.0
*/
public function objectExists($urn);
/**
* @param string $from the unified resource name used to identify the source object
* @param string $to the unified resource name used to identify the target object
* @return void
* @since 21.0.0
*/
public function copyObject($from, $to);
}
@@ -0,0 +1,59 @@
<?php
/*
* @copyright Copyright (c) 2021 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
declare(strict_types=1);
namespace OCP\Files\ObjectStore;
use Aws\Result;
/**
* @since 26.0.0
*/
interface IObjectStoreMultiPartUpload {
/**
* @since 26.0.0
*/
public function initiateMultipartUpload(string $urn): string;
/**
* @since 26.0.0
*/
public function uploadMultipartPart(string $urn, string $uploadId, int $partId, $stream, $size): Result;
/**
* @since 26.0.0
*/
public function completeMultipartUpload(string $urn, string $uploadId, array $result): int;
/**
* @since 26.0.0
*/
public function abortMultipartUpload(string $urn, string $uploadId): void;
/**
* @since 26.0.0
*/
public function getMultipartUploads(string $urn, string $uploadId): array;
}
@@ -0,0 +1,34 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
/**
* Exception for invalid path
* @since 8.1.0
*/
class ReservedWordException extends InvalidPathException {
}
@@ -0,0 +1,53 @@
<?php
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Search;
/**
* @since 12.0.0
*/
interface ISearchBinaryOperator extends ISearchOperator {
public const OPERATOR_AND = 'and';
public const OPERATOR_OR = 'or';
public const OPERATOR_NOT = 'not';
/**
* The type of binary operator
*
* One of the ISearchBinaryOperator::OPERATOR_* constants
*
* @return string
* @since 12.0.0
*/
public function getType();
/**
* The arguments for the binary operator
*
* One argument for the 'not' operator and two for 'and' and 'or'
*
* @return ISearchOperator[]
* @since 12.0.0
*/
public function getArguments();
}
@@ -0,0 +1,75 @@
<?php
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Maxence Lange <maxence@artificial-owl.com>
* @author Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Search;
/**
* @since 12.0.0
*/
interface ISearchComparison extends ISearchOperator {
public const COMPARE_EQUAL = 'eq';
public const COMPARE_GREATER_THAN = 'gt';
public const COMPARE_GREATER_THAN_EQUAL = 'gte';
public const COMPARE_LESS_THAN = 'lt';
public const COMPARE_LESS_THAN_EQUAL = 'lte';
public const COMPARE_LIKE = 'like';
public const COMPARE_LIKE_CASE_SENSITIVE = 'clike';
public const COMPARE_DEFINED = 'is-defined';
public const HINT_PATH_EQ_HASH = 'path_eq_hash'; // transform `path = "$path"` into `path_hash = md5("$path")`, on by default
/**
* Get the type of comparison, one of the ISearchComparison::COMPARE_* constants
*
* @return string
* @since 12.0.0
*/
public function getType(): string;
/**
* Get the name of the field to compare with
*
* i.e. 'size', 'name' or 'mimetype'
*
* @return string
* @since 12.0.0
*/
public function getField(): string;
/**
* extra means data are not related to the main files table
*
* @return string
* @since 28.0.0
*/
public function getExtra(): string;
/**
* Get the value to compare the field with
*
* @return string|integer|bool|\DateTime
* @since 12.0.0
*/
public function getValue(): string|int|bool|\DateTime;
}
@@ -0,0 +1,47 @@
<?php
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
* @author Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Search;
/**
* @since 12.0.0
*/
interface ISearchOperator {
/**
* Get a query builder hint by name
*
* @param string $name
* @param $default
* @return mixed
* @since 23.0.0
*/
public function getQueryHint(string $name, $default);
/**
* Get a query builder hint
*
* @param string $name
* @param $value
* @since 23.0.0
*/
public function setQueryHint(string $name, $value): void;
}
@@ -0,0 +1,69 @@
<?php
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Maxence Lange <maxence@artificial-owl.com>
* @author Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Search;
use OCP\Files\FileInfo;
/**
* @since 12.0.0
*/
interface ISearchOrder {
public const DIRECTION_ASCENDING = 'asc';
public const DIRECTION_DESCENDING = 'desc';
/**
* The direction to sort in, either ISearchOrder::DIRECTION_ASCENDING or ISearchOrder::DIRECTION_DESCENDING
*
* @return string
* @since 12.0.0
*/
public function getDirection(): string;
/**
* The field to sort on
*
* @return string
* @since 12.0.0
*/
public function getField(): string;
/**
* extra means data are not related to the main files table
*
* @return string
* @since 28.0.0
*/
public function getExtra(): string;
/**
* Apply the sorting on 2 FileInfo objects
*
* @param FileInfo $a
* @param FileInfo $b
* @return int -1 if $a < $b, 0 if $a = $b, 1 if $a > $b (for ascending, reverse for descending)
* @since 22.0.0
*/
public function sortFileInfo(FileInfo $a, FileInfo $b): int;
}
@@ -0,0 +1,76 @@
<?php
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
* @author Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\Search;
use OCP\IUser;
/**
* @since 12.0.0
*/
interface ISearchQuery {
/**
* @return ISearchOperator
* @since 12.0.0
*/
public function getSearchOperation();
/**
* Get the maximum number of results to return
*
* @return integer
* @since 12.0.0
*/
public function getLimit();
/**
* Get the offset for returned results
*
* @return integer
* @since 12.0.0
*/
public function getOffset();
/**
* The fields and directions to order by
*
* @return ISearchOrder[]
* @since 12.0.0
*/
public function getOrder();
/**
* The user that issued the search
*
* @return ?IUser
* @since 12.0.0
*/
public function getUser();
/**
* Whether or not the search should be limited to the users home storage
*
* @return bool
* @since 18.0.0
*/
public function limitToHome(): bool;
}
@@ -0,0 +1,124 @@
<?php
/**
* @copyright Copyright (c) 2016 Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Julius Härtl <jus@bitgrid.net>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\SimpleFS;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
/**
* This interface allows to manage simple files.
*
* This interface must not be implemented in your application but
* instead should be used as a service and injected in your code with
* dependency injection.
*
* @since 11.0.0
*/
interface ISimpleFile {
/**
* Get the name
*
* @since 11.0.0
*/
public function getName(): string;
/**
* Get the size in bytes
*
* @since 11.0.0
*/
public function getSize(): int|float;
/**
* Get the ETag
*
* @since 11.0.0
*/
public function getETag(): string;
/**
* Get the last modification time
*
* @since 11.0.0
*/
public function getMTime(): int;
/**
* Get the content
*
* @throws NotPermittedException
* @throws NotFoundException
* @since 11.0.0
*/
public function getContent(): string;
/**
* Overwrite the file
*
* @param string|resource $data
* @throws NotPermittedException
* @throws NotFoundException
* @since 11.0.0
*/
public function putContent($data): void;
/**
* Delete the file
*
* @throws NotPermittedException
* @since 11.0.0
*/
public function delete(): void;
/**
* Get the MimeType
*
* @since 11.0.0
*/
public function getMimeType(): string;
/**
* @since 24.0.0
*/
public function getExtension(): string;
/**
* Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen
*
* @return resource|false
* @throws \OCP\Files\NotPermittedException
* @since 14.0.0
*/
public function read();
/**
* Open the file as stream for writing, resulting resource can be operated as stream like the result from php's own fopen
*
* @return resource|bool
* @throws \OCP\Files\NotPermittedException
* @since 14.0.0
*/
public function write();
}
@@ -0,0 +1,100 @@
<?php
/**
* @copyright Copyright (c) 2016 Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\SimpleFS;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
/**
* Interface ISimpleFolder
*
* @since 11.0.0
*/
interface ISimpleFolder {
/**
* Get all the files in a folder
*
* @return ISimpleFile[]
* @since 11.0.0
*/
public function getDirectoryListing(): array;
/**
* Check if a file with $name exists
*
* @param string $name
* @return bool
* @since 11.0.0
*/
public function fileExists(string $name): bool;
/**
* Get the file named $name from the folder
*
* @throws NotFoundException
* @since 11.0.0
*/
public function getFile(string $name): ISimpleFile;
/**
* Creates a new file with $name in the folder
*
* @param string|resource|null $content @since 19.0.0
* @throws NotPermittedException
* @since 11.0.0
*/
public function newFile(string $name, $content = null): ISimpleFile;
/**
* Remove the folder and all the files in it
*
* @throws NotPermittedException
* @since 11.0.0
*/
public function delete(): void;
/**
* Get the folder name
*
* @since 11.0.0
*/
public function getName(): string;
/**
* Get the folder named $name from the current folder
*
* @throws NotFoundException
* @since 25.0.0
*/
public function getFolder(string $name): ISimpleFolder;
/**
* Creates a new folder with $name in the current folder
*
* @param string|resource|null $content @since 19.0.0
* @throws NotPermittedException
* @since 25.0.0
*/
public function newFolder(string $path): ISimpleFolder;
}
@@ -0,0 +1,62 @@
<?php
/**
* @copyright Copyright (c) 2016 Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\SimpleFS;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
/**
* Interface ISimpleRoot
*
* @since 11.0.0
*/
interface ISimpleRoot {
/**
* Get the folder with name $name
*
* @throws NotFoundException
* @throws \RuntimeException
* @since 11.0.0
*/
public function getFolder(string $name): ISimpleFolder;
/**
* Get all the Folders
*
* @return ISimpleFolder[]
* @throws NotFoundException
* @throws \RuntimeException
* @since 11.0.0
*/
public function getDirectoryListing(): array;
/**
* Create a new folder named $name
*
* @throws NotPermittedException
* @throws \RuntimeException
* @since 11.0.0
*/
public function newFolder(string $name): ISimpleFolder;
}
@@ -0,0 +1,156 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2018, Michael Weimann <mail@michael-weimann.eu>
*
* @author Michael Weimann <mail@michael-weimann.eu>
* @author Morris Jobke <hey@morrisjobke.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\Files\SimpleFS;
use OCP\Files\NotPermittedException;
/**
* This class represents a file that is only hold in memory.
*
* @since 16.0.0
*/
class InMemoryFile implements ISimpleFile {
/**
* Holds the file name.
*/
private string $name;
/**
* Holds the file contents.
*/
private string $contents;
/**
* InMemoryFile constructor.
*
* @param string $name The file name
* @param string $contents The file contents
* @since 16.0.0
*/
public function __construct(string $name, string $contents) {
$this->name = $name;
$this->contents = $contents;
}
/**
* @inheritdoc
* @since 16.0.0
*/
public function getName(): string {
return $this->name;
}
/**
* @inheritdoc
* @since 16.0.0
*/
public function getSize(): int|float {
return strlen($this->contents);
}
/**
* @inheritdoc
* @since 16.0.0
*/
public function getETag(): string {
return '';
}
/**
* @inheritdoc
* @since 16.0.0
*/
public function getMTime(): int {
return time();
}
/**
* @inheritdoc
* @since 16.0.0
*/
public function getContent(): string {
return $this->contents;
}
/**
* @inheritdoc
* @since 16.0.0
*/
public function putContent($data): void {
$this->contents = $data;
}
/**
* In memory files can't be deleted.
*
* @since 16.0.0
*/
public function delete(): void {
// unimplemented for in memory files
}
/**
* @inheritdoc
* @since 16.0.0
*/
public function getMimeType(): string {
$fileInfo = new \finfo(FILEINFO_MIME_TYPE);
return $fileInfo->buffer($this->contents);
}
/**
* {@inheritDoc}
* @since 24.0.0
*/
public function getExtension(): string {
return \pathinfo($this->name, PATHINFO_EXTENSION);
}
/**
* Stream reading is unsupported for in memory files.
*
* @throws NotPermittedException
* @since 16.0.0
*/
public function read() {
throw new NotPermittedException(
'Stream reading is unsupported for in memory files'
);
}
/**
* Stream writing isn't available for in memory files.
*
* @throws NotPermittedException
* @since 16.0.0
*/
public function write() {
throw new NotPermittedException(
'Stream writing is unsupported for in memory files'
);
}
}
+470
View File
@@ -0,0 +1,470 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author J0WI <J0WI@users.noreply.github.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author Robin McCorkell <robin@mccorkell.me.uk>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
* @author Vincent Petry <vincent@nextcloud.com>
* @author Vinicius Cubas Brand <vinicius@eita.org.br>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
use OCP\Files\Storage\IStorage;
use OCP\Lock\ILockingProvider;
/**
* Provide a common interface to all different storage options
*
* All paths passed to the storage are relative to the storage and should NOT have a leading slash.
*
* @since 6.0.0
* @deprecated 9.0.0 use \OCP\Files\Storage\IStorage instead
*/
interface Storage extends IStorage {
/**
* $parameters is a free form array with the configuration options needed to construct the storage
*
* @param array $parameters
* @since 6.0.0
*/
public function __construct($parameters);
/**
* Get the identifier for the storage,
* the returned id should be the same for every storage object that is created with the same parameters
* and two storage objects with the same id should refer to two storages that display the same files.
*
* @return string
* @since 6.0.0
*/
public function getId();
/**
* see https://www.php.net/manual/en/function.mkdir.php
* implementations need to implement a recursive mkdir
*
* @param string $path
* @return bool
* @since 6.0.0
*/
public function mkdir($path);
/**
* see https://www.php.net/manual/en/function.rmdir.php
*
* @param string $path
* @return bool
* @since 6.0.0
*/
public function rmdir($path);
/**
* see https://www.php.net/manual/en/function.opendir.php
*
* @param string $path
* @return resource|false
* @since 6.0.0
*/
public function opendir($path);
/**
* see https://www.php.net/manual/en/function.is-dir.php
*
* @param string $path
* @return bool
* @since 6.0.0
*/
public function is_dir($path);
/**
* see https://www.php.net/manual/en/function.is-file.php
*
* @param string $path
* @return bool
* @since 6.0.0
*/
public function is_file($path);
/**
* see https://www.php.net/manual/en/function.stat.php
* only the following keys are required in the result: size and mtime
*
* @param string $path
* @return array|bool
* @since 6.0.0
*/
public function stat($path);
/**
* see https://www.php.net/manual/en/function.filetype.php
*
* @param string $path
* @return string|bool
* @since 6.0.0
*/
public function filetype($path);
/**
* see https://www.php.net/manual/en/function.filesize.php
* The result for filesize when called on a folder is required to be 0
*
* @param string $path
* @return false|int|float
* @since 6.0.0
*/
public function filesize($path);
/**
* check if a file can be created in $path
*
* @param string $path
* @return bool
* @since 6.0.0
*/
public function isCreatable($path);
/**
* check if a file can be read
*
* @param string $path
* @return bool
* @since 6.0.0
*/
public function isReadable($path);
/**
* check if a file can be written to
*
* @param string $path
* @return bool
* @since 6.0.0
*/
public function isUpdatable($path);
/**
* check if a file can be deleted
*
* @param string $path
* @return bool
* @since 6.0.0
*/
public function isDeletable($path);
/**
* check if a file can be shared
*
* @param string $path
* @return bool
* @since 6.0.0
*/
public function isSharable($path);
/**
* get the full permissions of a path.
* Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php
*
* @param string $path
* @return int
* @since 6.0.0
*/
public function getPermissions($path);
/**
* see https://www.php.net/manual/en/function.file_exists.php
*
* @param string $path
* @return bool
* @since 6.0.0
*/
public function file_exists($path);
/**
* see https://www.php.net/manual/en/function.filemtime.php
*
* @param string $path
* @return int|bool
* @since 6.0.0
*/
public function filemtime($path);
/**
* see https://www.php.net/manual/en/function.file_get_contents.php
*
* @param string $path
* @return string|false
* @since 6.0.0
*/
public function file_get_contents($path);
/**
* see https://www.php.net/manual/en/function.file_put_contents.php
*
* @param string $path
* @param mixed $data
* @return int|float|false
* @since 6.0.0
*/
public function file_put_contents($path, $data);
/**
* see https://www.php.net/manual/en/function.unlink.php
*
* @param string $path
* @return bool
* @since 6.0.0
*/
public function unlink($path);
/**
* see https://www.php.net/manual/en/function.rename.php
*
* @param string $source
* @param string $target
* @return bool
* @since 6.0.0
*/
public function rename($source, $target);
/**
* see https://www.php.net/manual/en/function.copy.php
*
* @param string $source
* @param string $target
* @return bool
* @since 6.0.0
*/
public function copy($source, $target);
/**
* see https://www.php.net/manual/en/function.fopen.php
*
* @param string $path
* @param string $mode
* @return resource|bool
* @since 6.0.0
*/
public function fopen($path, $mode);
/**
* get the mimetype for a file or folder
* The mimetype for a folder is required to be "httpd/unix-directory"
*
* @param string $path
* @return string|bool
* @since 6.0.0
*/
public function getMimeType($path);
/**
* see https://www.php.net/manual/en/function.hash-file.php
*
* @param string $type
* @param string $path
* @param bool $raw
* @return string|bool
* @since 6.0.0
*/
public function hash($type, $path, $raw = false);
/**
* see https://www.php.net/manual/en/function.disk-free-space.php
*
* @param string $path
* @return int|float|bool
* @since 6.0.0
*/
public function free_space($path);
/**
* search for occurrences of $query in file names
*
* @param string $query
* @return array|bool
* @since 6.0.0
*/
public function search($query);
/**
* see https://www.php.net/manual/en/function.touch.php
* If the backend does not support the operation, false should be returned
*
* @param string $path
* @param int $mtime
* @return bool
* @since 6.0.0
*/
public function touch($path, $mtime = null);
/**
* get the path to a local version of the file.
* The local version of the file can be temporary and doesn't have to be persistent across requests
*
* @param string $path
* @return string|false
* @since 6.0.0
*/
public function getLocalFile($path);
/**
* check if a file or folder has been updated since $time
*
* @param string $path
* @param int $time
* @return bool
* @since 6.0.0
*
* hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed.
* returning true for other changes in the folder is optional
*/
public function hasUpdated($path, $time);
/**
* get the ETag for a file or folder
*
* @param string $path
* @return string|false
* @since 6.0.0
*/
public function getETag($path);
/**
* Returns whether the storage is local, which means that files
* are stored on the local filesystem instead of remotely.
* Calling getLocalFile() for local storages should always
* return the local files, whereas for non-local storages
* it might return a temporary file.
*
* @return bool true if the files are stored locally, false otherwise
* @since 7.0.0
*/
public function isLocal();
/**
* Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class
*
* @template T of IStorage
* @param string $class
* @psalm-param class-string<T> $class
* @return bool
* @since 7.0.0
* @psalm-assert-if-true T $this
*/
public function instanceOfStorage($class);
/**
* A custom storage implementation can return an url for direct download of a give file.
*
* For now the returned array can hold the parameter url - in future more attributes might follow.
*
* @param string $path
* @return array|bool
* @since 8.0.0
*/
public function getDirectDownload($path);
/**
* @param string $path the path of the target folder
* @param string $fileName the name of the file itself
* @return void
* @throws InvalidPathException
* @since 8.1.0
*/
public function verifyPath($path, $fileName);
/**
* @param IStorage $sourceStorage
* @param string $sourceInternalPath
* @param string $targetInternalPath
* @return bool
* @since 8.1.0
*/
public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath);
/**
* @param IStorage $sourceStorage
* @param string $sourceInternalPath
* @param string $targetInternalPath
* @return bool
* @since 8.1.0
*/
public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath);
/**
* @param string $path The path of the file to acquire the lock for
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @param \OCP\Lock\ILockingProvider $provider
* @throws \OCP\Lock\LockedException
* @since 8.1.0
*/
public function acquireLock($path, $type, ILockingProvider $provider);
/**
* @param string $path The path of the file to acquire the lock for
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @param \OCP\Lock\ILockingProvider $provider
* @throws \OCP\Lock\LockedException
* @since 8.1.0
*/
public function releaseLock($path, $type, ILockingProvider $provider);
/**
* @param string $path The path of the file to change the lock for
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @param \OCP\Lock\ILockingProvider $provider
* @throws \OCP\Lock\LockedException
* @since 8.1.0
*/
public function changeLock($path, $type, ILockingProvider $provider);
/**
* Test a storage for availability
*
* @since 8.2.0
* @return bool
*/
public function test();
/**
* @since 8.2.0
* @return array [ available, last_checked ]
*/
public function getAvailability();
/**
* @since 8.2.0
* @param bool $isAvailable
*/
public function setAvailability($isAvailable);
/**
* @since 12.0.0
* @return mixed
*/
public function needsPartFile();
}

Some files were not shown because too many files have changed in this diff Show More