Skip to content

fix: fix batch script Cyrillic paths and disk export backslash stripping on Windows#21245

Open
Mr-Charvaka wants to merge 4 commits into
darktable-org:masterfrom
Mr-Charvaka:fix/issues-20915-20981
Open

fix: fix batch script Cyrillic paths and disk export backslash stripping on Windows#21245
Mr-Charvaka wants to merge 4 commits into
darktable-org:masterfrom
Mr-Charvaka:fix/issues-20915-20981

Conversation

@Mr-Charvaka

Copy link
Copy Markdown

This PR resolves two Windows-specific issues:

  1. Fix purge_nonexistent_images.bat with Cyrillic paths (purge_nonexistent_images.bat removes existing files #20915):

    • Sets the active code page to 65001 (UTF-8) during the file existence check loop.
    • Redirects sqlite3 output to a temp file and reads it using usebackq inside for /f, avoiding the cmd.exe character truncation/corruption parser bug when executing subprocesses under CP 65001.
    • Quotes path parameters in if not exist "%%b" to correctly handle folders/filenames containing spaces.
  2. Fix Windows backslash path stripping in disk, gallery, and latex storage modules (Files are exported in a wrong location if using backslashes in the path #20981):

    • Cleans d->filename in the store() function on Windows by replacing all backslashes \ with forward slashes / before copying to the pattern string.
    • Forward slashes are natively supported as path separators by Windows filesystem APIs, and preventing backslashes in the pattern keeps them from being stripped as escape sequences during variable expansion.

…_images.bat

- Redirect sqlite3 output to a temporary file and read it from the file instead of running sqlite3 directly in the for loop. This avoids the cmd.exe character truncation/corruption parser bug when executing commands under UTF-8 code page 65001.
- Temporarily change code page to 65001 (UTF-8) during the file existence check loop so non-ASCII characters are interpreted correctly by the OS.
- Add quotes around path existence check to properly support paths containing spaces.

Fixes darktable-org#20915.
…th on Windows

- Replace all backslashes with forward slashes on Windows before variable expansion to prevent backslashes from being stripped as escape characters.
- Forward slashes are natively supported as path separators by Windows filesystem APIs, keeping directory structure intact.

Fixes darktable-org#20981.
…ort path on Windows

- Replace all backslashes with forward slashes on Windows before variable expansion to prevent backslashes from being stripped as escape characters.
- Forward slashes are natively supported as path separators by Windows filesystem APIs, keeping directory structure intact.

Related to darktable-org#20981.
…path on Windows

- Replace all backslashes with forward slashes on Windows before variable expansion to prevent backslashes from being stripped as escape characters.
- Forward slashes are natively supported as path separators by Windows filesystem APIs, keeping directory structure intact.

Related to darktable-org#20981.
@TurboGit

TurboGit commented Jun 6, 2026

Copy link
Copy Markdown
Member

@wpferguson : What's your view on those windows issues?

@wpferguson

Copy link
Copy Markdown
Member

If this PR was generated with AI assistance, please note that.

What kind of testing was done? Was it only tested to make sure the problem was fixed or was testing also done to make sure there were no regressions or issues created by the fix?

@wpferguson

Copy link
Copy Markdown
Member

What's your view on those windows issues?

@victoryforce would probably be the better one to ask about the Cyrillic issue.

I would recommend splitting this PR in 2 since it solves 2 problems that aren't really related except that they are both on Windows. It's easier to test one issue at and time and if necessary roll back one issue at a time.

@andriiryzhkov

Copy link
Copy Markdown
Collaborator

For the first part of this PR there is an earlier duplicate #20916

@Mr-Charvaka

Copy link
Copy Markdown
Author

I’ll carefully review the changes, and if any problems surface, I’ll create a new PR after thorough verification and keep you informed. thanks @wpferguson @andriiryzhkov !

@andriiryzhkov

Copy link
Copy Markdown
Collaborator

@Mr-Charvaka : It would be much better to split this PR into two separate addressing each issue individually. Especially considering first one is duplicate fix. Not saying it is better or worse though.

@andriiryzhkov

Copy link
Copy Markdown
Collaborator

@Mr-Charvaka : The purge_nonexistent_images.bat fix substantially overlaps with the open PR #20916 (same #20915 bug, same workaround pattern). That PR also catches two things this one doesn't:

  • %ids%!ids! in the two DELETE statements – without it the actual purge silently fails for multiple images
  • An endlocal for cleanup

Your codepage save/restore is nicer than #20916's blanket chcp though.

Could you drop the .bat changes here and let #20916 land? Your save/restore could go on top as a one-liner. Keeps the #20981 disk/gallery/latex backslash fix cleanly reviewable on its own.

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.

4 participants