Skip to content

Project download fails on Windows if project contains a folder with whitespace at the end of the folder name #693

@raherin

Description

@raherin

If a project contains a folder that has whitespace at the end of the folder name, the project will fail to download or sync on Windows machines. The issue is that Android, iOS and Linux support whitespace at the end of folder names so a project could contain such folders if they were created on a different OS or created by a photo naming expression where a subfolder is created based on the value of another field. When the project is downloaded in Windows, the OS automatically strips the whitespace from the photo name, resulting in an Unhandled Exception error.

To recreate the issue, download the attached project to a non-Windows machine.

-Unzip and open the project in QGIS
-Upload the project as a new project using the Mergin Maps QGIS Plugin
-Open QGIS on a Windows machine and try to download the project

You should get an error similar to the following:

2025-04-29 17:50:45,619 --- version: Python-client/0.10.0 Plugin/2025.1.1 QGIS/3.40.5 (Windows/11)
2025-04-29 17:50:45,619 --- start download support/folder_error
2025-04-29 17:50:45,839 got project info. version v2
2025-04-29 17:50:45,839 will download 3 files in 3 chunks, total size 3607529
2025-04-29 17:50:45,839 Downloading survey.gpkg version=v2 diff=False part=0
2025-04-29 17:50:45,839 Downloading folder_error.qgz version=v2 diff=False part=0
2025-04-29 17:50:45,839 Downloading photos /IMG_20231127_084655.jpg version=v2 diff=False part=0
2025-04-29 17:50:46,079 Download finished: folder_error.qgz
2025-04-29 17:50:46,079 Download finished: photos /IMG_20231127_084655.jpg
2025-04-29 17:50:46,094 Download finished: survey.gpkg
2025-04-29 17:50:46,350 Error while downloading project: Traceback (most recent call last):
  File "C:\PROGRA~1\QGIS34~1.5\apps\Python312\Lib\concurrent\futures\thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users/raahe/AppData/Roaming/QGIS/QGIS3\profiles\MM_support/python/plugins\Mergin\mergin\client_pull.py", line 95, in _do_download
    item.download_blocking(mc, mp, project_path)
  File "C:\Users/raahe/AppData/Roaming/QGIS/QGIS3\profiles\MM_support/python/plugins\Mergin\mergin\client_pull.py", line 324, in download_blocking
    save_to_file(resp, self.download_file_path)
  File "C:\Users/raahe/AppData/Roaming/QGIS/QGIS3\profiles\MM_support/python/plugins\Mergin\mergin\utils.py", line 39, in save_to_file
    with open(path, "wb") as output:
         ^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\raahe\\Documents\\Projects\\folder_error\\folder_error\\photos \\IMG_20231127_084655.jpg.0'

2025-04-29 17:50:46,350 --- download aborted

folder_error.zip

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions