smallAreaHealthStatisticsUnit / rapidInquiryFacility

The Rapid Inquiry Facility (RIF) helps epidemiologists and public health researchers in environmental health activities.
GNU Lesser General Public License v3.0
14 stars 5 forks source link

Improve file handling #109

Closed devilgate closed 5 years ago

devilgate commented 5 years ago

Improving the File Handling

Future Proofing

I've put all access to files behind a new interface called AppFile. At the moment that just returns instances of TomcatFile, which is now the sole implementation of AppFile. But I foresee a time when we, or a user, might want to run the RIF on another platform, or as a standalone app. If and when that time comes, this change will make it easier to adapt to the new environment.

A Single Place for Changes

This change also means that we only have to change one place if application paths change, or other possibilities become available.

File Locking

As well as that I've gone through all the places where files are used and made sure that Readers are closed, and so on.

There are a number of places where we pass a File object into a library function, so we have to rely on that library being well behaved and closing its resources, but that's just business as usual.

So this should fix #108.