Skip to content

Commit 81bebc3

Browse files
committed
address review comments
Signed-off-by: Anupam Kumar <kyteinsky@gmail.com>
1 parent eb0ef6f commit 81bebc3

20 files changed

+42
-44
lines changed

lib/BackgroundJobs/ActionJob.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(
3838
}
3939

4040
private function getJobInterval(): int {
41-
return intval($this->appConfig->getAppValueString('action_job_interval', (string)(5 * 60), true)); // 5 minutes
41+
return intval($this->appConfig->getAppValueString('action_job_interval', (string)(5 * 60), lazy: true)); // 5 minutes
4242
}
4343

4444
protected function run($argument): void {

lib/BackgroundJobs/FileSystemListenerJob.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(
4848
}
4949

5050
private function getJobInterval(): int {
51-
return intval($this->appConfig->getAppValueString('fs_listener_job_interval', (string)(5 * 60), true)); // 5 minutes
51+
return intval($this->appConfig->getAppValueString('fs_listener_job_interval', (string)(5 * 60), lazy: true)); // 5 minutes
5252
}
5353

5454
protected function run($argument): void {

lib/BackgroundJobs/IndexerJob.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function run($argument): void {
9191

9292
$this->storageId = $argument['storageId'];
9393
$this->rootId = $argument['rootId'];
94-
if ($this->appConfig->getAppValueString('auto_indexing', 'true', true) === 'false') {
94+
if ($this->appConfig->getAppValueString('auto_indexing', 'true', lazy: true) === 'false') {
9595
return;
9696
}
9797
$this->diagnosticService->sendJobTrigger(static::class, $this->getId());
@@ -149,19 +149,19 @@ public function run($argument): void {
149149
}
150150

151151
protected function getBatchSize(): int {
152-
return $this->appConfig->getAppValueInt('indexing_batch_size', self::DEFAULT_BATCH_SIZE, true);
152+
return $this->appConfig->getAppValueInt('indexing_batch_size', self::DEFAULT_BATCH_SIZE, lazy: true);
153153
}
154154

155155
protected function getMaxIndexingTime(): int {
156-
return $this->appConfig->getAppValueInt('indexing_max_time', self::DEFAULT_MAX_INDEXING_TIME, true);
156+
return $this->appConfig->getAppValueInt('indexing_max_time', self::DEFAULT_MAX_INDEXING_TIME, lazy: true);
157157
}
158158

159159
protected function getJobInterval(): int {
160-
return $this->appConfig->getAppValueInt('indexing_job_interval', self::DEFAULT_JOB_INTERVAL, true);
160+
return $this->appConfig->getAppValueInt('indexing_job_interval', self::DEFAULT_JOB_INTERVAL, lazy: true);
161161
}
162162

163163
protected function getMaxSize(): float {
164-
return (float)$this->appConfig->getAppValueInt('indexing_max_size', Application::CC_MAX_SIZE, true);
164+
return (float)$this->appConfig->getAppValueInt('indexing_max_size', Application::CC_MAX_SIZE, lazy: true);
165165
}
166166

167167
/**
@@ -321,7 +321,7 @@ protected function index(array $files): void {
321321
}
322322

323323
private function setInitialIndexCompletion(): void {
324-
if ($this->appConfig->getAppValueInt('last_indexed_time', 0, true) !== 0) {
324+
if ($this->appConfig->getAppValueInt('last_indexed_time', 0, lazy: true) !== 0) {
325325
return;
326326
}
327327
try {
@@ -345,7 +345,7 @@ private function setInitialIndexCompletion(): void {
345345
}
346346

347347
$this->logger->info('Initial index completion detected, setting last indexed time');
348-
$this->appConfig->setAppValueInt('last_indexed_time', $this->timeFactory->getTime(), true);
348+
$this->appConfig->setAppValueInt('last_indexed_time', $this->timeFactory->getTime(), lazy: true);
349349
}
350350

351351
/**

lib/BackgroundJobs/RotateLogsJob.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(
2828

2929
protected function run($argument): void {
3030
$default = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/context_chat.log';
31-
$this->filePath = $this->appConfig->getAppValueString('logfile', $default, true);
31+
$this->filePath = $this->appConfig->getAppValueString('logfile', $default, lazy: true);
3232

3333
$this->maxSize = $this->config->getSystemValue('log_rotate_size', 100 * 1024 * 1024);
3434

lib/BackgroundJobs/SchedulerJob.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ public function __construct(
3434
* @throws Exception
3535
*/
3636
protected function run($argument): void {
37-
// todo: non-lazy since this needs to change often in one process, like in the diagnostics service
38-
$this->appConfig->setAppValueString('indexed_files_count', (string)0, false);
39-
$this->appConfig->setAppValueInt('last_indexed_time', 0, true);
37+
$this->appConfig->setAppValueString('indexed_files_count', (string)0, lazy: true);
38+
$this->appConfig->setAppValueInt('last_indexed_time', 0, lazy: true);
4039
foreach ($this->storageService->getMounts() as $mount) {
4140
$this->logger->debug('Scheduling StorageCrawlJob storage_id=' . $mount['storage_id'] . ' root_id=' . $mount['root_id' ] . 'override_root=' . $mount['overridden_root']);
4241
$this->jobList->add(StorageCrawlJob::class, [

lib/BackgroundJobs/StorageCrawlJob.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ protected function run($argument): void {
9090

9191
if ($lastSuccessfulFileId !== -1) {
9292
// the last job to set this value will win
93-
$this->appConfig->setAppValueInt('last_indexed_file_id', $lastSuccessfulFileId, true);
93+
$this->appConfig->setAppValueInt('last_indexed_file_id', $lastSuccessfulFileId, lazy: true);
9494
}
9595
}
9696
} finally {
@@ -99,6 +99,6 @@ protected function run($argument): void {
9999
}
100100

101101
protected function getJobInterval(): int {
102-
return $this->appConfig->getAppValueInt('crawl_job_interval', self::DEFAULT_JOB_INTERVAL, true);
102+
return $this->appConfig->getAppValueInt('crawl_job_interval', self::DEFAULT_JOB_INTERVAL, lazy: true);
103103
}
104104
}

lib/BackgroundJobs/SubmitContentJob.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected function run($argument): void {
6363
return;
6464
}
6565

66-
$maxSize = $this->appConfig->getAppValueInt('indexing_max_size', Application::CC_MAX_SIZE, true);
66+
$maxSize = $this->appConfig->getAppValueInt('indexing_max_size', Application::CC_MAX_SIZE, lazy: true);
6767

6868
if (empty($entities)) {
6969
return;

lib/Command/Statistics.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ protected function configure() {
4242

4343
protected function execute(InputInterface $input, OutputInterface $output): int {
4444
$output->writeln('ContextChat statistics:');
45-
if ($this->appConfig->getAppValueInt('last_indexed_time', 0, true) === 0) {
45+
if ($this->appConfig->getAppValueInt('last_indexed_time', 0, lazy: true) === 0) {
4646
$output->writeln('The indexing is not complete yet.');
4747
} else {
48-
$installedTime = $this->appConfig->getAppValueInt('installed_time', 0, true);
49-
$lastIndexedTime = $this->appConfig->getAppValueInt('last_indexed_time', 0, true);
48+
$installedTime = $this->appConfig->getAppValueInt('installed_time', 0, lazy: true);
49+
$lastIndexedTime = $this->appConfig->getAppValueInt('last_indexed_time', 0, lazy: true);
5050
$indexTime = $lastIndexedTime - $installedTime;
5151

5252
$output->writeln('Installed time: ' . (new \DateTime('@' . $installedTime))->format('Y-m-d H:i') . ' UTC');
@@ -66,7 +66,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6666
$queuedDocumentsCount = $this->contentQueue->count();
6767
$output->writeln('Queued documents (without files):' . var_export($queuedDocumentsCount, true));
6868

69-
$indexFilesCount = Util::numericToNumber(intval($this->appConfig->getAppValueString('indexed_files_count', '0', false)));
69+
$indexFilesCount = Util::numericToNumber(intval($this->appConfig->getAppValueString('indexed_files_count', '0', lazy: true)));
7070
$output->writeln('Files successfully sent to backend: ' . strval($indexFilesCount));
7171

7272
$indexedDocumentsCount = $this->langRopeService->getIndexedDocumentsCounts();

lib/Controller/ConfigController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function setConfig(array $values): DataResponse {
5151
*/
5252
public function setAdminConfig(array $values): DataResponse {
5353
foreach ($values as $key => $value) {
54-
$this->appConfig->setAppValueString($key, $value, true);
54+
$this->appConfig->setAppValueString($key, $value, lazy: true);
5555
}
5656
return new DataResponse(1);
5757
}

lib/Logger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(
3434

3535
public function getLogFilepath(): string {
3636
$default = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/context_chat.log';
37-
return $this->appConfig->getAppValueString('logfile', $default, true);
37+
return $this->appConfig->getAppValueString('logfile', $default, lazy: true);
3838
}
3939

4040
public function emergency(Stringable|string $message, array $context = []): void {

0 commit comments

Comments
 (0)