0

I am writing a package manager in python for users to install programs we write at work.

When 'installing' a new tool (which is just a process of copying files/folders from locations on a server to the users' computer), it may fail before completion for whatever reason.

If this happens, I need a way to 'undo' all the changes made on the users' PC (I remove anything that was copied across).

What techniques are there to implement this sort of 'revert' functionality?

(Windows only solution)

jramm
  • 6,415
  • 4
  • 34
  • 73

2 Answers2

0

Use a distributed RCS (Revision Control System) such as Git, Bazaar or Mercurial so you can easily transfer files while still checking if everything was transferred correctly.

Updating will simply be a git/bzr/hg pull, reverting to an old version will be checkout out a tag.

Wolph
  • 78,177
  • 11
  • 137
  • 148
  • Not sure this is suitable because while the package manager only has to move files around, to 'install' stuff, it doesn't necessarily want to copy the package 'as is' from source control/server. The is a 'meta' file each package is expected to contain with instructions on how to install. – jramm Feb 13 '15 at 13:28
  • Doesn't matter, you are currently copying files/folders and that's what you can use an RCS for. The added advantage of these RCS systems is that they'll check if everything transferred correctly – Wolph Feb 13 '15 at 13:32
0

You could have two solutions

First is to 1. copy the files into a temp folder and on success 2. remove the old folder 3. move the temp folder into the new one if

Second is to 1.copy the files into a directory, versioned by name, something like C:\Programs\v2, v3, v4 etc. 2. If everything is ok, you create a junction point or a symlink to the destination you want.

Tasos Vogiatzoglou
  • 2,393
  • 12
  • 16