Skip to content

Commit

Permalink
force delete entry on reset
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed Oct 24, 2023
1 parent c89df97 commit 1b13b8e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
16 changes: 6 additions & 10 deletions lib/private/FilesMetadata/FilesMetadataManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,14 @@ public function refreshMetadata(
int $process = self::PROCESS_LIVE,
bool $fromScratch = false,
): IFilesMetadata {
$metadata = null;
if (!$fromScratch) {
try {
$metadata = $this->metadataRequestService->getMetadataFromFileId($node->getId());
} catch (FilesMetadataNotFoundException $e) {
}
if ($fromScratch) {
$this->deleteMetadata($node->getId());
}

if (null === $metadata) {
// if $fromScratch, we reset all and new empty FilesMetadata will
// erase the one stored in db even if it stays empty.
$metadata = new FilesMetadata($node->getId(), $fromScratch);
try {
$metadata = $this->metadataRequestService->getMetadataFromFileId($node->getId());
} catch (FilesMetadataNotFoundException $e) {
$metadata = new FilesMetadata($node->getId());
}

// is $process is LIVE, we enforce LIVE
Expand Down
4 changes: 2 additions & 2 deletions lib/private/FilesMetadata/Model/FilesMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ class FilesMetadata implements IFilesMetadata {

/** @var array<string, MetadataValueWrapper> */
private array $metadata = [];
private bool $updated = false;
private int $lastUpdate = 0;
private string $syncToken = '';

public function __construct(
private int $fileId = 0,
private bool $updated = false
private int $fileId = 0
) {
}

Expand Down

0 comments on commit 1b13b8e

Please sign in to comment.