Question

We are working on a web app using django that will allow for modification of files which are stored in a vcs repo (currently git).

Writing to the file in the local workspace will be done as long as edit runs in browser. Adding/committing will happen when user is finished with editing (save) or after a given time lapse.

Because there will be parallel web sessions running, I am concerned by the concurrent access to the versioned files :

  • when reading / writing in the local workspace
  • as we want commit messages to contain messages specific to each file's modification, we also need some kind of lock to prevent add - commit operations to interlace.

So I guess we should use some kind of locking and am looking for a mechanism which is robust and compatible with the web app architecture :

  • I read about flocks, but I guess it is not adapted to a stateless application; I probably cannot hold a filehandle easily, can I ?
  • I could create some kinds of filename.ext.lock files to programmatically handle mutual access exclusion
  • Or I could have a dedicated table in db for the same goal
  • Other solution would be to delegate vcs accesses (file and repo) to a dedicated process, but I couldn't find anything yet; searching for git daemon only return results that deal with operating on whole repos for clone / push / pull / ..., not for file level operations

Do you see other means than the ones above ? Do you know of aspects we should specially take care of ?

No correct solution

OTHER TIPS

I agree with Magnus Bäck. Unlike SVN you can create different copies of git-repos and merge them into one another without a server, just on your local machine. So you can have a bunch of copies of the same repository and each client/process gets its own folder. You can delete and copy them when you need more or less.

Also you can do

git remote add local_original file:///var/git/project.git 

(source)

in each copy and use this for

git push local_original

to push the changes to this local repository to synchronize all users working on it.

I would go in favor of copying because it can scale better than locks. Here is something that I implemented that does not have to scale but that I would implement with copying if it had to: https://github.com/niccokunzmann/gh-pages-edit

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top