fixed more indentations

This commit is contained in:
Jonathan Treffler 2025-07-02 14:46:05 +02:00
parent acf8990de1
commit f031591753
9 changed files with 148 additions and 148 deletions

View file

@ -19,29 +19,29 @@ class AdminSettingsController extends Controller {
);
}
/**
* @return JSONResponse
*/
public function index(): JSONResponse {
return new JSONResponse($this->settingsService->getAppValues());
}
/**
* @return JSONResponse
*/
public function index(): JSONResponse {
return new JSONResponse($this->settingsService->getAppValues());
}
/**
* @param $key
*
* @return JSONResponse
*/
public function show($key): JSONResponse {
return new JSONResponse($this->settingsService->getAppValue($key));
}
/**
* @param $key
*
* @return JSONResponse
*/
public function show($key): JSONResponse {
return new JSONResponse($this->settingsService->getAppValue($key));
}
/**
* @param $key
* @param $value
*
* @return JSONResponse
*/
public function update($key, $value): JSONResponse {
/**
* @param $key
* @param $value
*
* @return JSONResponse
*/
public function update($key, $value): JSONResponse {
return new JSONResponse($this->settingsService->setAppValue($key, $value));
}
}
}

View file

@ -7,25 +7,25 @@ use OCP\AppFramework\Db\Entity;
class DiffTask extends Entity implements JsonSerializable {
protected $userId;
protected $groupfolderId;
protected $userId;
protected $groupfolderId;
protected $relativePath;
protected $snapshotId;
protected $timestamp;
protected $snapshotId;
protected $timestamp;
public function __construct() {
$this->addType('id','integer');
$this->addType('groupfolderId','integer');
}
public function __construct() {
$this->addType('id','integer');
$this->addType('groupfolderId','integer');
}
public function jsonSerialize() {
return [
'id' => $this->id,
public function jsonSerialize() {
return [
'id' => $this->id,
'userId' => $this->userId,
'groupfolderId' => $this->groupfolderId,
'groupfolderId' => $this->groupfolderId,
'relativePath' => $this->relativePath,
'snapshotId' => $this->snapshotId,
'timestamp' => $this->timestamp,
];
}
'snapshotId' => $this->snapshotId,
'timestamp' => $this->timestamp,
];
}
}

View file

@ -9,29 +9,29 @@ use OCP\AppFramework\Db\QBMapper;
*/
class DiffTaskMapper extends QBMapper {
public function __construct(IDBConnection $db) {
parent::__construct($db, 'groupfolder_snapshots_tasks', DiffTask::class);
}
public function __construct(IDBConnection $db) {
parent::__construct($db, 'groupfolder_snapshots_tasks', DiffTask::class);
}
public function find(int $id, string $userId) {
$qb = $this->db->getQueryBuilder();
public function find(int $id, string $userId) {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName())
->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
->andWhere($qb->expr()->eq('user_id', $qb->createNamedParameter($userId)));
$qb->select('*')
->from($this->getTableName())
->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
->andWhere($qb->expr()->eq('user_id', $qb->createNamedParameter($userId)));
return $this->findEntity($qb);
}
return $this->findEntity($qb);
}
public function findAll(string $userId) {
$qb = $this->db->getQueryBuilder();
public function findAll(string $userId) {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName())
->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId)));
$qb->select('*')
->from($this->getTableName())
->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId)));
return $this->findEntities($qb);
}
return $this->findEntities($qb);
}
}

View file

@ -7,49 +7,49 @@ use OCP\AppFramework\Db\Entity;
class DiffTaskResult extends Entity implements JsonSerializable {
protected $taskId;
protected $timestamp;
protected $type;
protected $taskId;
protected $timestamp;
protected $type;
protected $beforeFileExists;
protected $beforePath;
protected $beforeSize;
protected $beforeFileExists;
protected $beforePath;
protected $beforeSize;
protected $currentFileExists;
protected $currentFileId;
protected $currentFileExists;
protected $currentFileId;
protected $currentPath;
protected $currentSize;
protected $currentSize;
protected $reverted;
public function __construct() {
$this->addType('id','integer');
$this->addType('taskId','integer');
$this->addType('beforeFileExists','boolean');
$this->addType('beforeSize','integer');
$this->addType('currentFileExists','boolean');
public function __construct() {
$this->addType('id','integer');
$this->addType('taskId','integer');
$this->addType('beforeFileExists','boolean');
$this->addType('beforeSize','integer');
$this->addType('currentFileExists','boolean');
$this->addType('currentFileId','integer');
$this->addType('currentSize','integer');
$this->addType('currentSize','integer');
$this->addType('reverted','boolean');
}
}
public function jsonSerialize() {
return [
'id' => $this->id,
'taskId' => $this->taskId,
'type' => $this->type,
'before' => [
'fileExists' => $this->beforeFileExists,
'path' => $this->beforePath,
'size' => $this->beforeSize,
],
'current' => [
'fileExists' => $this->currentFileExists,
public function jsonSerialize() {
return [
'id' => $this->id,
'taskId' => $this->taskId,
'type' => $this->type,
'before' => [
'fileExists' => $this->beforeFileExists,
'path' => $this->beforePath,
'size' => $this->beforeSize,
],
'current' => [
'fileExists' => $this->currentFileExists,
'fileId' => $this->currentFileId,
'path' => $this->currentPath,
'size' => $this->currentSize,
'path' => $this->currentPath,
'size' => $this->currentSize,
],
'reverted' => $this->reverted,
];
}
];
}
}

View file

@ -9,29 +9,29 @@ use OCP\AppFramework\Db\QBMapper;
*/
class DiffTaskResultMapper extends QBMapper {
public function __construct(IDBConnection $db) {
parent::__construct($db, 'groupfolder_snapshots_task_results', DiffTaskResult::class);
}
public function __construct(IDBConnection $db) {
parent::__construct($db, 'groupfolder_snapshots_task_results', DiffTaskResult::class);
}
public function find(int $id) {
$qb = $this->db->getQueryBuilder();
public function find(int $id) {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName())
->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
$qb->select('*')
->from($this->getTableName())
->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
return $this->findEntity($qb);
}
return $this->findEntity($qb);
}
public function findAll(int $taskId) {
$qb = $this->db->getQueryBuilder();
public function findAll(int $taskId) {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName())
->where($qb->expr()->eq('task_id', $qb->createNamedParameter($taskId)));
$qb->select('*')
->from($this->getTableName())
->where($qb->expr()->eq('task_id', $qb->createNamedParameter($taskId)));
return $this->findEntities($qb);
}
return $this->findEntities($qb);
}
public function markReverted(int $id) {
$taskResult = $this->find($id);

View file

@ -5,12 +5,12 @@ namespace OCA\GroupfolderFilesystemSnapshots\Entity;
use JsonSerializable;
class Snapshot implements JsonSerializable {
public function __construct(
public function __construct(
private string $id,
private string $name,
private ?\DateTimeImmutable $createdTimestamp = null,
) {
}
}
public function getId(): string {
return $this->id;
@ -24,7 +24,7 @@ class Snapshot implements JsonSerializable {
return $this->createdTimestamp;
}
public function jsonSerialize(): mixed {
public function jsonSerialize(): mixed {
return [
'id' => $this->id,
'name' => $this->name,

View file

@ -3,34 +3,34 @@
namespace OCA\GroupfolderFilesystemSnapshots\Helpers;
class FileHelper {
private static function seperateFilesFromFolders($parentDir, $items) {
$files = [];
$folders = [];
private static function seperateFilesFromFolders($parentDir, $items) {
$files = [];
$folders = [];
foreach($items as $item) {
if(is_dir($parentDir . DIRECTORY_SEPARATOR . $item)) {
$folders[] = $item;
} else {
$files[] = $item;
}
}
foreach($items as $item) {
if(is_dir($parentDir . DIRECTORY_SEPARATOR . $item)) {
$folders[] = $item;
} else {
$files[] = $item;
}
}
return array($files, $folders);
}
return array($files, $folders);
}
public static function getFilesAndFolders($dir) {
$scan = array_diff(scandir($dir), array('..', '.'));
public static function getFilesAndFolders($dir) {
$scan = array_diff(scandir($dir), array('..', '.'));
return self::seperateFilesFromFolders($dir, $scan);
}
return self::seperateFilesFromFolders($dir, $scan);
}
public static function getFilesizesOfFiles($prefix, array $files) {
$result = array();
public static function getFilesizesOfFiles($prefix, array $files) {
$result = array();
foreach($files as $index=>$file) {
$result[$index] = filesize($prefix . DIRECTORY_SEPARATOR . $file);
}
foreach($files as $index=>$file) {
$result[$index] = filesize($prefix . DIRECTORY_SEPARATOR . $file);
}
return $result;
}
return $result;
}
}

View file

@ -28,7 +28,7 @@ class SettingsService {
}
}
public function setAppValue(string $key, string $value): string {
public function setAppValue(string $key, string $value): string {
if(in_array($key, self::$VALID_APP_SETTINGS)) {
if($value !== '') {
$this->config->setAppValue(Application::APP_ID, $key, $value);
@ -38,5 +38,5 @@ class SettingsService {
return $value;
}
}
}
}

View file

@ -6,21 +6,21 @@ use OCP\Settings\ISettings;
class SnapshotsAdmin implements ISettings {
public function __construct() {
}
public function __construct() {
}
/**
* @return TemplateResponse
*/
public function getForm() {
return new TemplateResponse('groupfolder_filesystem_snapshots', 'settings/admin');
}
/**
* @return TemplateResponse
*/
public function getForm() {
return new TemplateResponse('groupfolder_filesystem_snapshots', 'settings/admin');
}
public function getSection() {
return 'groupfolder_filesystem_snapshots';
}
public function getSection() {
return 'groupfolder_filesystem_snapshots';
}
public function getPriority() {
return 10;
}
public function getPriority() {
return 10;
}
}