Skip to content

Preserve product conversions and shared photos when copying - #1008

Open
exquisiteskink wants to merge 1 commit into
patzly:masterfrom
exquisiteskink:fix/safe-product-copy
Open

exquisiteskink wants to merge 1 commit into
patzly:masterfrom
exquisiteskink:fix/safe-product-copy

Conversation

@exquisiteskink

Copy link
Copy Markdown

Copying a product currently loses its product-specific unit conversions, and removing a copied photo can delete the image still used by the original product. Copy independent conversion pairs, update automatically created target conversions, and support legacy purchase factors on older Grocy servers. Clone the source product before editing the copy. Removing or replacing a photo updates only that product's reference after a successful server response.

Product creation and conversion writes use POST requests without automatic retries. If conversion copying fails after creation, retain the created product ID in the editor so retrying resumes that product, including after rotation. Re-read conversion rows before retrying a write whose response may have been lost.

Fixes #948.
Fixes #1004.

Validation:

  • 8 Robolectric regression tests covering source isolation, conversions, failed and lost-response retries, legacy factors, shared-photo removal/replacement, and failed photo updates.
  • Fold6 / Android 16 against an isolated Grocy 4.7.1 server: copied both conversion pairs and their inverse rows; removed the copied photo while preserving the original reference and image file; injected a conversion failure, rotated, and retried successfully without creating another product.
  • :app:testDebugUnitTest :app:assembleDebug :app:lintDebug completed successfully; no additional lint findings compared with upstream master.
  • All four related fixes merge without conflicts and pass 32 tests together.

Tradeoffs: unreferenced image files remain on the server because another product may share them. Copying uses multiple API requests; a conversion failure leaves a partial product until the editor retries. The retained retry state survives rotation, but is not persisted across process death.

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.

App removes photos referenced by other products Copying a product resets factors in QU conversions

1 participant