2019-12-03 21:57:53 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-10-12 18:42:08 +03:00
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
|
|
|
|
*
|
2020-03-31 11:49:10 +03:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Robin Appelman <robin@icewind.nl>
|
|
|
|
*
|
2018-10-12 18:42:08 +03:00
|
|
|
* @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
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2018-10-12 18:42:08 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\Files_Versions\Versions;
|
|
|
|
|
|
|
|
use OCP\Files\File;
|
|
|
|
use OCP\Files\FileInfo;
|
|
|
|
use OCP\Files\NotFoundException;
|
2019-05-21 18:14:47 +03:00
|
|
|
use OCP\Files\Storage\IStorage;
|
2018-10-12 18:42:08 +03:00
|
|
|
use OCP\IUser;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @since 15.0.0
|
|
|
|
*/
|
|
|
|
interface IVersionBackend {
|
2019-05-21 18:14:47 +03:00
|
|
|
/**
|
|
|
|
* Whether or not this version backend should be used for a storage
|
|
|
|
*
|
|
|
|
* If false is returned then the next applicable backend will be used
|
|
|
|
*
|
|
|
|
* @param IStorage $storage
|
|
|
|
* @return bool
|
|
|
|
* @since 17.0.0
|
|
|
|
*/
|
|
|
|
public function useBackendForStorage(IStorage $storage): bool;
|
|
|
|
|
2018-10-12 18:42:08 +03:00
|
|
|
/**
|
|
|
|
* Get all versions for a file
|
|
|
|
*
|
|
|
|
* @param IUser $user
|
|
|
|
* @param FileInfo $file
|
|
|
|
* @return IVersion[]
|
|
|
|
* @since 15.0.0
|
|
|
|
*/
|
|
|
|
public function getVersionsForFile(IUser $user, FileInfo $file): array;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new version for a file
|
|
|
|
*
|
|
|
|
* @param IUser $user
|
|
|
|
* @param FileInfo $file
|
|
|
|
* @since 15.0.0
|
|
|
|
*/
|
|
|
|
public function createVersion(IUser $user, FileInfo $file);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Restore this version
|
|
|
|
*
|
|
|
|
* @param IVersion $version
|
|
|
|
* @since 15.0.0
|
|
|
|
*/
|
|
|
|
public function rollback(IVersion $version);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open the file for reading
|
|
|
|
*
|
|
|
|
* @param IVersion $version
|
|
|
|
* @return resource
|
|
|
|
* @throws NotFoundException
|
|
|
|
* @since 15.0.0
|
|
|
|
*/
|
|
|
|
public function read(IVersion $version);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the preview for a specific version of a file
|
|
|
|
*
|
|
|
|
* @param IUser $user
|
|
|
|
* @param FileInfo $sourceFile
|
2019-06-04 14:39:23 +03:00
|
|
|
* @param int|string $revision
|
2020-03-06 18:33:01 +03:00
|
|
|
*
|
|
|
|
* @return File
|
|
|
|
*
|
2018-10-12 18:42:08 +03:00
|
|
|
* @since 15.0.0
|
|
|
|
*/
|
2019-06-04 14:39:23 +03:00
|
|
|
public function getVersionFile(IUser $user, FileInfo $sourceFile, $revision): File;
|
2018-10-12 18:42:08 +03:00
|
|
|
}
|