4 ms·
I'll add this: If you have to deal with state (e.g.: say you write something akin to `git checkout` that should rearrange the file system): Combine this strateg
by btschaegg 4y ago
I'll add this: If you have to deal with state (e.g.: say you write something akin to `git checkout` that should rearrange the file system): Combine this strategy with the question of "can I roll this step back?".
I.e. for a checkout:
- Make a temporary folder on the target disk (rollback: delete it)
- Create new files for those you have to change (rollback: delete them)
- Fill these files with their target content
- Move old files away into the temp folder
- Move new files into place
- If everything worked, delete the leftovers (the only thing that can't be rolled back)
Your disk fills up during checkout? Roll back!
You're on Windows and some file is blocked by another process? Roll back!
…etc. :)