Added a Setting to set the Model Download Folder - #1557
Open
a4blue wants to merge 1 commit into
Open
Conversation
Signed-off-by: Alexander Ratajczak <a4blue@hotmail.de>
a4blue
force-pushed
the
customize-model-download-location
branch
from
August 15, 2026 21:27
b782a1e to
796d972
Compare
Contributor
There was a problem hiding this comment.
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 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'] |
Member
There was a problem hiding this comment.
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)