python - Update Two Related Files On Disk In a "Secure" Way? -


I have two binary files that are related to one another (i.e., when a file's update is updated The second file is recorded to match the match should also be updated). Both files are binary files stored on disk.

UpdateFirstFile () - The first file has been updated ... ..

The update will appear something like this:

UpdateFirstFile () - The first file has been updated ... ..

UpdateSecondFile () - The second file has been updated ...

What methods should I use to ensure that both files are updated or from files Have not got any updates?

Both files are flat files (size 20 [MB] each). I know that a database would have solved this problem, however I'm using one due to overhead reasons (more than 20 [MB] in each table needs to be stored, and I'm less on space And 1000s of such files .. ..).

Any thoughts?

Any kind of rollback journal should be implemented with the general viewpoint.

For example, you can use a different file to record the current content of each part in each file, which will be affected by the update. After your transaction is complete, you remove the journal file.

The presence of journal files upon the transaction will mean that another transaction is either pending or interrupted. In that situation, you use the contents of the journal to reverse any file changes that went before the interruption.

In this way, you will leave any other part of the update operation that you need as a practice for the reader.

Keep in mind that this is correct the right path is harder than it seems, especially if you have multiple processes updating the same file.

Comments