import_ovpack(on_conflict="overwrite") deletes the existing resource before writing, so a failed import loses both versions

Aperta
#7,433 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Kiko0301 ci sta già lavorando.

Dal 11/11/2026.

  • #7421 di @Kiko0301 — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
20/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Read openviking/storage/ovpack/operations.py, especially _remove_existing_root() and the import_ovpack() member-writing loop. PR #7421 describes the proposed backup and restore behavior, and the issue says two regression tests fail on main; inspect those tests and verify that a failed member write preserves the old resource. The issue already has an open pull request.

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

Descrizione

import_ovpack(..., on_conflict="overwrite") deletes the existing root before writing the package

Bug Description

import_ovpack() (openviking/storage/ovpack/operations.py:263) handles overwrite by calling _remove_existing_root() (operations.py:127) for every existing root and only then iterating the package members with mkdir / write_file_bytes (operations.py:343-368). The delete is not reversible and the member loop is not transactional.

Any failure during the member loop — a storage timeout, a full disk, an ACL error, process cancellation — leaves the destination with the new files partially written and the previous resource permanently deleted. The function raises, but neither the old nor the new version is intact.

Steps to Reproduce

  1. Import a pack at viking://resources/demo, producing a.txt and b.txt.
  2. Import a second pack for the same root with on_conflict="overwrite".
  3. Make write_file_bytes fail for one member (e.g. b.txt) mid-import.

Expected Behavior

The failed import leaves the previous resource at viking://resources/demo intact, so the caller can retry.

Actual Behavior

The previous root was deleted before the member writes; the destination holds a partially written new root, and the previous a.txt / b.txt are gone.

Environment

  • OS: Windows 11
  • OpenViking version/commit: main @ 95d96162

Additional Context

Fix submitted as PR #7421: the existing root is moved to <root>.ovpack-backup-<uuid> before writing, restored if the member loop fails, and discarded after a successful write. Filesystems without mv keep the previous delete-then-write behavior. Two regression tests fail on unmodified main.

Lingua principale
Python
Stelle
41.8k
Fork
3.4k
Merge medio
19h 29m
PR unite (30g)
500

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 volcengine/OpenViking

Tutte le issue di volcengine/OpenViking

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.