Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove .ome from file name generated #468

Merged
merged 1 commit into from
Mar 11, 2025
Merged
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
17 changes: 15 additions & 2 deletions packages/core/services/DatabaseService/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,26 @@ export default abstract class DatabaseService {
`);
// Best shot attempt at auto-generating a "File Name"
// from the "File Path", defaults to full path if this fails
// description of SQL:
// * COALESCE - returns the first non-null value in the list
// * NULLIF - returns null if the two arguments are equal
// * REGEXP_REPLACE - replaces a substring with another substring
// so we first replace the last file extension with nothing
// then check if .ome is at the end of the string and remove it
// then if it is null if the string is empty
// which we use COALESCE to replace with the full path if so
commandsToExecute.push(`
UPDATE "${name}"
SET "${PreDefinedColumn.FILE_NAME}" = COALESCE(
NULLIF(
REGEXP_REPLACE(
"${PreDefinedColumn.FILE_PATH}",
'^.*/([^/]*?)(\\.[^/.]+)?$', '\\1',
REGEXP_REPLACE(
"${PreDefinedColumn.FILE_PATH}",
'^.*/([^/]*?)(\\.[^/.]+)?$',
'\\1',
''
),
'\\.ome$',
''
),
''),
Expand Down