Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ concurrency:

jobs:
scan-test:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

strategy:
# do not stop on another job's failure
Expand Down Expand Up @@ -223,6 +223,9 @@ jobs:
run: |
cd context_chat_backend
pip install --upgrade pip setuptools wheel
# use the cpu version of torch to not run out of space
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
sed -i '/torch(vision)?/d' requirements.txt
pip install -r requirements.txt
cp example.env .env
echo "NEXTCLOUD_URL=http://localhost:8080" >> .env
Expand Down Expand Up @@ -338,7 +341,7 @@ jobs:
tail -v -n +1 context_chat_backend/persistent_storage/logs/* || echo "No logs in logs directory"

cron-test:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

strategy:
# do not stop on another job's failure
Expand Down Expand Up @@ -482,6 +485,9 @@ jobs:
run: |
cd context_chat_backend
pip install --upgrade pip setuptools wheel
# use the cpu version of torch to not run out of space
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
sed -i '/torch(vision)?/d' requirements.txt
pip install -r requirements.txt
cp example.env .env
echo "NEXTCLOUD_URL=http://localhost:8080" >> .env
Expand Down Expand Up @@ -643,7 +649,7 @@ jobs:
tail -v -n +1 context_chat_backend/persistent_storage/logs/* || echo "No logs in logs directory"

listener-test:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

strategy:
# do not stop on another job's failure
Expand Down Expand Up @@ -791,6 +797,9 @@ jobs:
run: |
cd context_chat_backend
pip install --upgrade pip setuptools wheel
# use the cpu version of torch to not run out of space
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
sed -i '/torch(vision)?/d' requirements.txt
pip install -r requirements.txt
cp example.env .env
echo "NEXTCLOUD_URL=http://localhost:8080" >> .env
Expand Down
35 changes: 28 additions & 7 deletions lib/Service/MetadataService.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace OCA\ContextChat\Service;

use OC\Files\SetupManager;
use OCA\ContextChat\Logger;
use OCA\ContextChat\Public\ContentManager;
use OCA\ContextChat\Public\IContentProvider;
Expand Down Expand Up @@ -166,14 +167,34 @@ public function getEnrichedSources(string $userId, string ...$sources): array {
}
}

# for files
foreach ($sources as $source) {
if (!str_starts_with($source, ProviderConfigService::getDefaultProviderKey() . ': ')) {
continue;
}
$enrichedSources[] = $this->getMetadataObjectForId($userId, $source);
$setupManager = \OCP\Server::get(SetupManager::class);
$user = $this->userManager->get($userId);

if ($user === null) {
$this->logger->warning('User not found for enriching sources', ['userId' => $userId]);
return $enrichedSources;
}

return $enrichedSources;
try {
$setupManager->setupForUser($user);
} catch (\Throwable $e) {
$this->logger->error('Error setting up filesystem for user ' . $userId . ': ' . $e->getMessage(), ['exception' => $e]);
return $enrichedSources;
}

try {
# for files
foreach ($sources as $source) {
if (!str_starts_with($source, ProviderConfigService::getDefaultProviderKey() . ': ')) {
continue;
}
$enrichedSources[] = $this->getMetadataObjectForId($userId, $source);
}
} catch (\Throwable $e) {
$this->logger->error('Error enriching file sources: ' . $e->getMessage(), ['exception' => $e]);
} finally {
$setupManager->tearDown();
return $enrichedSources;
}
}
}
7 changes: 7 additions & 0 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@
<code><![CDATA[getDistinctMounts]]></code>
</UndefinedInterfaceMethod>
</file>
<file src="lib/Service/MetadataService.php">
<UndefinedClass>
<code><![CDATA[$setupManager]]></code>
<code><![CDATA[\OCP\Server::get(SetupManager::class)]]></code>
<code><![CDATA[SetupManager]]></code>
</UndefinedClass>
</file>
</files>
Loading