Skip to content

Commit

Permalink
v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
eldertek committed Dec 18, 2024
1 parent 367d922 commit 05a1bed
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.3.0 - 2024-12-18
### Fixed
- Error during occ update:check when no user context is available
- Database migration issue with MySQL when column length exceeded maximum key length

## 1.2.9 - 2024-12-17
### Added
- Origin folders configuration to protect files from deletion
Expand Down
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<summary lang="fr">Économisez de l’espace en trouvant vos fichiers en doublon</summary>
<description>Are you tired of sifting through piles of files and folders, only to discover multiple copies of the same content cluttering your storage space?</description>
<description lang="fr">Vous en avez assez de passer au crible des piles de fichiers et de dossiers pour découvrir que plusieurs copies du même contenu encombrent votre espace de stockage ?</description>
<version>1.2.9</version>
<version>1.3.0</version>
<licence>agpl</licence>
<author mail="andrelauret@eclipse-technology.eu" >André Théo LAURET</author>
<namespace>DuplicateFinder</namespace>
Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version0009Date20240116000000.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
]);
$table->addColumn('folder_path', 'string', [
'notnull' => true,
'length' => 4000,
'length' => 700,
]);
$table->addColumn('created_at', 'datetime', [
'notnull' => true,
Expand Down
12 changes: 12 additions & 0 deletions lib/Service/FileDuplicateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class FileDuplicateService
private $fileInfoService;
/** @var OriginFolderService */
private $originFolderService;
/** @var ?string */
private $currentUserId = null;

public function __construct(
LoggerInterface $logger,
Expand All @@ -39,6 +41,13 @@ public function __construct(
$this->originFolderService = $originFolderService;
}

public function setCurrentUserId(?string $userId): void {
$this->currentUserId = $userId;
if ($this->originFolderService !== null) {
$this->originFolderService->setUserId($userId);
}
}

/**
* @return FileDuplicate
*/
Expand Down Expand Up @@ -96,6 +105,9 @@ public function findAll(
bool $enrich = false,
?array $orderBy = [['hash'], ['type']]
): array {
if ($user !== null) {
$this->setCurrentUserId($user);
}
$this->logger->debug('Finding duplicates with parameters: type={type}, user={user}, page={page}, pageSize={pageSize}, enrich={enrich}', [
'type' => $type ?? 'all',
'user' => $user ?? 'none',
Expand Down
18 changes: 16 additions & 2 deletions lib/Service/OriginFolderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,26 @@ class OriginFolderService {
public function __construct(
OriginFolderMapper $mapper,
IRootFolder $rootFolder,
string $userId,
?string $userId,
LoggerInterface $logger
) {
$this->mapper = $mapper;
$this->rootFolder = $rootFolder;
$this->userId = $userId;
$this->userId = $userId ?? '';
$this->logger = $logger;
}

private function validateUserContext(): void {
if (empty($this->userId)) {
throw new \RuntimeException('User context required for this operation');
}
}

/**
* @return array
*/
public function findAll(): array {
$this->validateUserContext();
return $this->mapper->findAll($this->userId);
}

Expand All @@ -46,6 +53,7 @@ public function findAll(): array {
* @throws Exception if the folder is already an origin folder
*/
public function create(string $folderPath): OriginFolder {
$this->validateUserContext();
$this->logger->debug('Creating origin folder: {path}', ['path' => $folderPath]);

// Verify that the folder exists
Expand Down Expand Up @@ -79,6 +87,7 @@ public function create(string $folderPath): OriginFolder {
* @throws MultipleObjectsReturnedException
*/
public function delete(int $id): OriginFolder {
$this->validateUserContext();
try {
$originFolder = $this->mapper->find($id);
if ($originFolder->getUserId() !== $this->userId) {
Expand All @@ -97,6 +106,7 @@ public function delete(int $id): OriginFolder {
* @return array{isProtected: bool, protectingFolder: string|null}
*/
public function isPathProtected(string $path): array {
$this->validateUserContext();
$originFolders = $this->findAll();
foreach ($originFolders as $folder) {
$folderPath = $folder->getFolderPath();
Expand All @@ -114,4 +124,8 @@ public function isPathProtected(string $path): array {
'protectingFolder' => null
];
}

public function setUserId(?string $userId): void {
$this->userId = $userId ?? '';
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "duplicatefinder",
"description": "Save some space by finding your duplicate files",
"version": "1.2.9",
"version": "1.3.0",
"author": "André Théo LAURET <andrelauret@eclipse-technology.eu>",
"contributors": [],
"bugs": {
Expand Down

0 comments on commit 05a1bed

Please sign in to comment.