JMMC-OpenDev / oiexplorer

GNU General Public License v3.0
2 stars 1 forks source link

[bug] adding twice a file with the same filepath gives inconsistent collection state #10

Closed buthanoid closed 2 years ago

buthanoid commented 2 years ago

What is the problem

If I add a file. If I add another time a file of the same filepath. Then OIFitsCollection uses the updated file content, and OIDataCollection uses the old file content. This is an inconsistent state.

What did you expect

Both collections to be updated. Every reference to the old OIFitsFile object must disappear.

Describe how to reproduce or add a test

Context information

Technical details

The culprit is the function OIFitsCollectionManager.addOIFitsFile. It calls OIFitsCollection.addOIFitsFile which replaces the old OIFitsFile object by the new one, and then it does not do the same for OIDataCollection, whereas it should. BTW there is a related TODO in OIFItsCollection.addOIFitsFile

buthanoid commented 2 years ago

technical problem

solution 1

solution 2

bourgesl commented 2 years ago

I think this bug is related to missing reference checks... I am implementing now.

Anyway I agree solution 2 is expected: explicit update any or first oidatafile reference ( as filepath is unique) is better