2019-12-03 13:57:53 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2018-10-12 11:42:08 -04:00
|
|
|
/**
|
2024-06-02 09:26:54 -04:00
|
|
|
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2018-10-12 11:42:08 -04:00
|
|
|
*/
|
|
|
|
|
namespace OCA\Files_Versions\Versions;
|
|
|
|
|
|
2025-07-05 16:28:49 -04:00
|
|
|
use OC\Files\Node\Node;
|
2018-10-12 11:42:08 -04:00
|
|
|
use OCP\Files\File;
|
|
|
|
|
use OCP\Files\FileInfo;
|
|
|
|
|
use OCP\Files\NotFoundException;
|
2019-05-21 11:14:47 -04:00
|
|
|
use OCP\Files\Storage\IStorage;
|
2018-10-12 11:42:08 -04:00
|
|
|
use OCP\IUser;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 15.0.0
|
|
|
|
|
*/
|
|
|
|
|
interface IVersionBackend {
|
2019-05-21 11:14:47 -04: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 11:42:08 -04: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
|
2023-03-13 13:59:16 -04:00
|
|
|
* @return resource|false
|
2018-10-12 11:42:08 -04:00
|
|
|
* @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 07:39:23 -04:00
|
|
|
* @param int|string $revision
|
2020-03-06 10:33:01 -05:00
|
|
|
*
|
|
|
|
|
* @return File
|
|
|
|
|
*
|
2018-10-12 11:42:08 -04:00
|
|
|
* @since 15.0.0
|
|
|
|
|
*/
|
2019-06-04 07:39:23 -04:00
|
|
|
public function getVersionFile(IUser $user, FileInfo $sourceFile, $revision): File;
|
2025-07-05 16:28:49 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the revision for a node
|
|
|
|
|
*
|
|
|
|
|
* @since 32.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function getRevision(Node $node): int;
|
2018-10-12 11:42:08 -04:00
|
|
|
}
|