added admin settings service and api; made filesystem paths configurable; added babel config; added admin settings webpack config

This commit is contained in:
Jonathan Treffler 2024-04-23 19:51:41 +02:00 committed by root
parent 188ea3dfa9
commit b79f6cab6b
12 changed files with 10224 additions and 32 deletions

View file

@ -4,33 +4,30 @@ namespace OCA\GroupfolderFilesystemSnapshots\Manager;
use OCP\IConfig;
use OCP\Files\IRootFolder;
use OCA\GroupFolders\Folder\FolderManager;
use OCA\GroupFolders\Mount\MountProvider;
class PathManager {
private IConfig $config;
private IRootFolder $rootFolder;
private FolderManager $groupfolderFolderManager;
/** @var MountProvider */
protected $mountProvider;
use OCA\GroupfolderFilesystemSnapshots\Service\SettingsService;
const FILESYSTEM_ROOT_PATH = "/srv/nextcloud/files/";
const FILESYSTEM_SNAPSHOT_PATH = "/srv/nextcloud/files/.zfs/snapshot/";
class PathManager {
//const FILESYSTEM_ROOT_PATH = "/srv/nextcloud/files/";
//const FILESYSTEM_SNAPSHOT_PATH = "/srv/nextcloud/files/.zfs/snapshot/";
public function __construct(
IConfig $config,
IRootFolder $rootFolder,
FolderManager $manager,
MountProvider $mountProvider,
){
$this->config = $config;
$this->groupfolderFolderManager = $manager;
$this->rootFolder = $rootFolder;
$this->mountProvider = $mountProvider;
private IConfig $config,
private IRootFolder $rootFolder,
private FolderManager $groupfolderFolderManager,
private MountProvider $mountProvider,
private SettingsService $settingsService,
){}
public function getFilesystemMountpointPath() {
return $this->settingsService->getAppValue("filesystem_mountpoint_path");
}
public function getFilesystemSnapshotPath() {
return self::FILESYSTEM_SNAPSHOT_PATH;
public function getFilesystemSnapshotsPath() {
return $this->settingsService->getAppValue("filesystem_snapshots_path");
}
// Nextcloud general
@ -44,17 +41,22 @@ class PathManager {
// Snapshots
public function getSnapshotPath(string $snapshotId) {
return realpath(self::FILESYSTEM_SNAPSHOT_PATH . DIRECTORY_SEPARATOR . $snapshotId . DIRECTORY_SEPARATOR);
return realpath($this->getFilesystemSnapshotsPath() . DIRECTORY_SEPARATOR . $snapshotId . DIRECTORY_SEPARATOR);
}
public function convertToSnapshotPath(string $filesystemPath, string $snapshotId) {
$filesystemMountpointPath = $this->getFilesystemMountpointPath();
$filesystemPath = realpath($filesystemPath);
if(!str_starts_with($filesystemPath, self::FILESYSTEM_ROOT_PATH)) {
if($filesystemMountpointPath == '') {
return false;
}
return str_replace(self::FILESYSTEM_ROOT_PATH, $this->getSnapshotPath($snapshotId) . DIRECTORY_SEPARATOR, $filesystemPath);
if(!str_starts_with($filesystemPath, $filesystemMountpointPath)) {
return false;
}
return str_replace($filesystemMountpointPath, $this->getSnapshotPath($snapshotId) . DIRECTORY_SEPARATOR, $filesystemPath);
}
// Groupfolders