[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] JGit thread safety

On Fri, Apr 19, 2013 at 12:28 AM, Dimitar Georgiev
<dimitar.georgiev.bg@xxxxxxxxx> wrote:
> Thanks! I will try out the DirCache API today.

The advantage here is you may be able to work completely in-memory and
not need a working-directory per-user. This may be a cleaner
implementation.

> In the meantime, I'd like to add that by design of my system each user's
> contents resides in a separate FS folder and each add / commit operation
> operates on only one user folder. If I ensure locking around the folder if
> many request by one user occur, does this change anything and make my app
> thread-safe?

Yes. If you use your own lock to ensure only 1 request is trying to
operate on each checkout this will be fine. As I said the internals of
JGit are thread-safe, but the parts that handle a working directory
are not since they assume the caller manages serialization of each
working directory.

> If not, I will take up the index approach.
>
> Ultimately I need a repo with a working folder, to make the submitted
> content available to a static HTTP server.
> In this case would I need two repos? One to write resources and commit info,
> and one which only pulls and checks out from the other, and serves the HTTP
> server?

You may want to use a separate working directory for the content the
static HTTP server is presenting. After changes are updated in the Git
repository, serialize on this single directory to checkout the latest
version(s).