Skip to content

Added a Setting to set the Model Download Folder - #1557

Open
a4blue wants to merge 1 commit into
nextcloud:mainfrom
a4blue:customize-model-download-location
Open

Added a Setting to set the Model Download Folder#1557
a4blue wants to merge 1 commit into
nextcloud:mainfrom
a4blue:customize-model-download-location

Conversation

@a4blue

@a4blue a4blue commented Aug 15, 2026

Copy link
Copy Markdown

This should fix #1160
In order to be compatible with existing users i added a repair step to move the old Files to the new Location

馃 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Signed-off-by: Alexander Ratajczak <a4blue@hotmail.de>
@a4blue
a4blue force-pushed the customize-model-download-location branch from b782a1e to 796d972 Compare August 15, 2026 21:27
@marcelklehr
marcelklehr requested a balanced review from Copilot August 26, 2026 08:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a configurable model download location and migrates existing models.

Changes:

  • Adds model-path settings and admin UI.
  • Updates model downloading and status checks.
  • Adds an upgrade repair step for existing models.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/components/ViewAdmin.vue Adds model-path controls and status.
package-lock.json Updates package version metadata.
lib/Settings/AdminSettings.php Provides model-path status.
lib/Service/SettingsService.php Defines and resolves the path setting.
lib/Service/DownloadModelsService.php Downloads models to the configured location.
lib/Migration/MoveDefaultModelFolder.php Migrates existing model files.
appinfo/info.xml Registers the migration step.

馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +32 to +33
$targetPath = $this->settingsService->getSetting('models_target_path');
$modelPath = $targetPath . '/models';
Comment on lines +50 to 52
$archivePath = $targetPath . '/models.tar.gz';
$timeout = $this->isCLI ? 0 : 480;
$this->clientService->newClient()->get($archiveUrl, ['sink' => $archivePath, 'timeout' => $timeout]);
$modelsPath = __DIR__ . '/../../models';
$modelsDownloaded = file_exists($modelsPath);
$targetPath = $this->settingsService->getSetting('models_target_path');
$modelsDownloaded = file_exists($targetPath .' /models');
Comment on lines +59 to +60
foreach ($filesToMove as $file) {
rename($file, $newModelTargetPath.'/'.basename($file));
Comment thread appinfo/info.xml
Comment on lines 102 to +107
<post-migration>
<step>OCA\Recognize\Migration\InstallDeps</step>
</post-migration>
<post-migration>
<step>OCA\Recognize\Migration\MoveDefaultModelFolder</step>
</post-migration>
}

const SETTINGS = ['tensorflow.cores', 'tensorflow.gpu', 'tensorflow.purejs', 'imagenet.enabled', 'landmarks.enabled', 'faces.enabled', 'musicnn.enabled', 'movinet.enabled', 'node_binary', 'ffmpeg_binary', 'faces.status', 'imagenet.status', 'landmarks.status', 'movinet.status', 'musicnn.status', 'faces.lastFile', 'imagenet.lastFile', 'landmarks.lastFile', 'movinet.lastFile', 'musicnn.lastFile', 'faces.batchSize', 'imagenet.batchSize', 'landmarks.batchSize', 'movinet.batchSize', 'musicnn.batchSize', 'clusterFaces.status', 'clusterFaces.lastRun', 'nice_binary', 'nice_value', 'concurrency.enabled', 'taskprocessing.enabled']
const SETTINGS = ['tensorflow.cores', 'tensorflow.gpu', 'tensorflow.purejs', 'imagenet.enabled', 'landmarks.enabled', 'faces.enabled', 'musicnn.enabled', 'movinet.enabled', 'node_binary', 'ffmpeg_binary', 'faces.status', 'imagenet.status', 'landmarks.status', 'movinet.status', 'musicnn.status', 'faces.lastFile', 'imagenet.lastFile', 'landmarks.lastFile', 'movinet.lastFile', 'musicnn.lastFile', 'faces.batchSize', 'imagenet.batchSize', 'landmarks.batchSize', 'movinet.batchSize', 'musicnn.batchSize', 'clusterFaces.status', 'clusterFaces.lastRun', 'nice_binary', 'nice_value', 'concurrency.enabled', 'taskprocessing.enabled', 'models_target_path', 'models_archive_file']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing is probably not what we want though. We should add it to SettingsService

Comment on lines +217 to +225
private function isPathAbsolute(string $path): bool {
if ($path === '') {
return false;
}
if ($path[0] === '/') {
return true;
}

return false;

if (is_dir($oldModelTargetPath)) {
$filesToMove = scandir($oldModelTargetPath);
$filesToMove = array_filter($filesToMove, fn ($value) => $value !== '.' && $value === '..');
$filesToMove = scandir($oldModelTargetPath);
$filesToMove = array_filter($filesToMove, fn ($value) => $value !== '.' && $value === '..');
$filesToMove = array_map(fn ($value) => $oldModelTargetPath.'/'.$value, $filesToMove);
mkdir($newModelTargetPath);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add option to customize model download location

3 participants