in reply to Move files w/ commit-rollback mechanism?

Something like this?

  1. Create a transaction ID, $id. Just use $$ and check for collisions (or hope for no collisions).
  2. Write a transaction journal file (probably just use a good temp-file module) that contains source and destination pairs (and whether it is a move or copy, if you want to support both).
  3. Copy all of the files to the destination file system with names something like ".$id.$desiredFinalName", checking for collisions so you can abort the "transaction".
  4. Wait for a commit request
  5. For each file that was moved:
    1. Append a line to the transaction journal saying you are about to rename the file
    2. Rename the source file to ".$id.$origFileName"
    3. Append a line to the journal saying you have finished renaming the file
  6. For each destination file:
    1. Append a line to the journal saying you are about to rename the file
    2. Rename the file to $desiredFinalName
    3. Append a line to the journal saying you finished renaming
  7. Remove the journal for the successfully committed transaction
if something fails then you use the journal to rollback.

                - tye
  • Comment on Re: Move files w/ commit-rollback mechanism? (journaled move)