IVersionBackend.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php declare(strict_types=1);
  2. /**
  3. * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
  4. *
  5. * @license GNU AGPL version 3 or any later version
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Affero General Public License as
  9. * published by the Free Software Foundation, either version 3 of the
  10. * License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. namespace OCA\Files_Versions\Versions;
  22. use OCP\Files\File;
  23. use OCP\Files\FileInfo;
  24. use OCP\Files\NotFoundException;
  25. use OCP\Files\SimpleFS\ISimpleFile;
  26. use OCP\Files\Storage\IStorage;
  27. use OCP\IUser;
  28. /**
  29. * @since 15.0.0
  30. */
  31. interface IVersionBackend {
  32. /**
  33. * Whether or not this version backend should be used for a storage
  34. *
  35. * If false is returned then the next applicable backend will be used
  36. *
  37. * @param IStorage $storage
  38. * @return bool
  39. * @since 17.0.0
  40. */
  41. public function useBackendForStorage(IStorage $storage): bool;
  42. /**
  43. * Get all versions for a file
  44. *
  45. * @param IUser $user
  46. * @param FileInfo $file
  47. * @return IVersion[]
  48. * @since 15.0.0
  49. */
  50. public function getVersionsForFile(IUser $user, FileInfo $file): array;
  51. /**
  52. * Create a new version for a file
  53. *
  54. * @param IUser $user
  55. * @param FileInfo $file
  56. * @since 15.0.0
  57. */
  58. public function createVersion(IUser $user, FileInfo $file);
  59. /**
  60. * Restore this version
  61. *
  62. * @param IVersion $version
  63. * @since 15.0.0
  64. */
  65. public function rollback(IVersion $version);
  66. /**
  67. * Open the file for reading
  68. *
  69. * @param IVersion $version
  70. * @return resource
  71. * @throws NotFoundException
  72. * @since 15.0.0
  73. */
  74. public function read(IVersion $version);
  75. /**
  76. * Get the preview for a specific version of a file
  77. *
  78. * @param IUser $user
  79. * @param FileInfo $sourceFile
  80. * @param int|string $revision
  81. * @return ISimpleFile
  82. * @since 15.0.0
  83. */
  84. public function getVersionFile(IUser $user, FileInfo $sourceFile, $revision): File;
  85. }