Skip to content

Cannot package attached files if QGIS and export directory are the same #704

@SGroe

Description

@SGroe

What is the bug or the crash? What were your expectations and what actually happened?

The following Python error occurs when the project is packaged to the directory where the QGIS project is stored.

2025-08-06T10:44:32     WARNING    Traceback (most recent call last):
              File "C:\Users/GIS/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qfieldsync\gui\package_dialog.py", line 260, in package_project
              raise err
              File "C:\Users/GIS/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qfieldsync\gui\package_dialog.py", line 253, in package_project
              self._offline_convertor.convert()
              File "C:\Users\GIS\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\qfieldsync\libqfieldsync_0d143dd958c38595bca8ade31293521182f7a3a2.whl\libqfieldsync\offline_converter.py", line 164, in convert
              self._convert(project)
              File "C:\Users\GIS\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\qfieldsync\libqfieldsync_0d143dd958c38595bca8ade31293521182f7a3a2.whl\libqfieldsync\offline_converter.py", line 374, in _convert
              copy_attachments(
              File "C:\Users\GIS\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\qfieldsync\libqfieldsync_0d143dd958c38595bca8ade31293521182f7a3a2.whl\libqfieldsync\utils\file_utils.py", line 158, in copy_attachments
              shutil.copyfile(filename, dest_filename)
              File "C:\OSGeo4W\apps\Python312\Lib\shutil.py", line 240, in copyfile
              raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
             shutil.SameFileError: WindowsPath('G:/xxx/Dokumente/ktn_gis/xxx/.fonts/BEV_DKM_Symbole_05_2012.ttf') and WindowsPath('G:/xxx/Dokumente/ktn_gis/xxx/.fonts/BEV_DKM_Symbole_05_2012.ttf') are the same file

Usually, I select another directory as destination. I recommend to either force to copy to another directory, or maybe just ignore the exception.

Steps to reproduce the issue

  1. Package project (with attached files) to directory where the QGIS project is stored

QGIS version

3.40.9

QFieldSync Version

4.15.2

Operating system name

Windows

Operating system version

Windows 11

Reinstall QFieldSync

  • I have a fresh install of the latest QFieldSync version on a new QGIS profile, but the problem persists.
  • Problem can be reliably reproduced, doesn't happen randomly.
  • Problem happens with all files and projects, not only some files or projects.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions