Project history and Remove locally fail in projects with long paths on Windows (> 260 characters)

Aperta
#967 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
desktop

Direzione di ricerca

Both failures are long-path (>260 char) issues: Mergin/diff.py near line 386 (make_version_changes_layers) opens the cached .mergin/.cache/...schema.json, and Mergin/data_item.py line 215 (_delete_project_dir) walks the cache to delete it. Reproduce with the PowerShell snippet, then trace how those paths are built and where Windows long-path handling is missing. Done when Project history opens without the dialog and Remove locally deletes the folder completely.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug windows

Description
In a project stored in a long folder on Windows, syncing works, but two plugin features show FileNotFoundError:

  • Project history: an error dialog appears when the window opens. After closing it, the history shows the changes.
  • Remove locally: an error appears and the project folder is left partly deleted.

It happens when files in the project's .mergin folder exceed 260 characters. In short-path projects both features work without errors.

Environment
[x] Staging [x] PROD

Application (+ app version, build, operating system)
QGIS 3.44.15-Solothurn, Mergin Maps plugin master (python-api-client 0.15.1, geodiff 2.3.2), Windows 11 64-bit Arm. LongPathsEnabled = 1 and 0 (same result).

Steps to reproduce

  1. On Windows, create a folder about 215 characters long, e.g. in PowerShell:
    $target = 215; $p = "C:\mmlong"
    while ($p.Length + 51 -le $target) { $p = Join-Path $p ("a"*50) }
    $p = Join-Path $p ("b" * ($target - $p.Length - 1))
    New-Item -ItemType Directory -Path $p -Force | Out-Null; $p.Length
    
  2. In QGIS, Browser → Mergin Maps → right-click a project with a GeoPackage → Download into that folder.
  3. Open the project, add a feature to the GeoPackage layer, save and sync.
  4. Click Project history on the Mergin Maps toolbar.
  5. Close the error dialog, the history window and the project (Project → Close).
  6. In the Browser, right-click the project → Remove locally.

Actual results

  • Step 4: an error dialog appears when the history window opens. After closing it, the history shows the changes.
    FileNotFoundError: [Errno 2] No such file or directory: '…\issue954_lv95\.mergin\.cache\v22\observations.gpkg-schema.json'
      File "Mergin\diff.py", line 386, in make_version_changes_layers
    
  • Step 6: an error appears and the project folder isn't fully removed (17 files left):
    FileNotFoundError: [WinError 3] The system cannot find the path specified: '…\issue954_lv95\.mergin\.cache\v25\observations.gpkg'
      File "Mergin\data_item.py", line 215, in _delete_project_dir
    

Expected results

  • Step 4: Project history opens without an error, as in short-path projects.
  • Step 6: The local project folder is removed completely, as in short-path projects.

Screenshots or logs

An error has occurred while executing Python code: 

FileNotFoundError: [Errno 2] No such file or directory: 'C:/mm932/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bb/issue954_lv95\\.mergin\\.cache\\v22\\observations.gpkg-schema.json' 
Traceback (most recent call last):
  File "C:\Users/mrcic/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Mergin\version_viewer_dialog.py", line 589, in selected_version_changed
    self.show_version_changes(version)
  File "C:\Users/mrcic/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Mergin\version_viewer_dialog.py", line 676, in show_version_changes
    layers = make_version_changes_layers(QgsProject.instance().homePath(), version)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users/mrcic/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Mergin\diff.py", line 386, in make_version_changes_layers
    with open(schema_file, encoding="utf-8") as fl:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:/mm932/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bb/issue954_lv95\\.mergin\\.cache\\v22\\observations.gpkg-schema.json'


Python version: 3.12.15 (main, Oct  2 2026, 17:29:02) [MSC v.1944 64 bit (AMD64)] 
QGIS version: 3.44.15-Solothurn Solothurn, 44b4ef05178 

Conclusion
Created by Claude and supervised by a human test analyst.

Lingua principale
Python
Stelle
45
Fork
21
Merge medio
3g 13h
PR unite (30g)
2

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di MerginMaps/qgis-plugin

Tutte le issue di MerginMaps/qgis-plugin

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.