Home Forums Software ELAN File locking

File locking

This topic contains 16 replies, has 5 voices, and was last updated by  cschenk 6 days, 10 hours ago.

Viewing 10 posts - 1 through 10 (of 17 total)
Author Posts
Author Posts
July 9, 2018 at 09:44 #12321

odenbach

Hi,

one of our research groups wants to use ELAN. They use our group network storage to store the eaf files. They realized that ELAN does not use any kind of locking mechanism. So it is possible that two people from different computers open the same file simultaneously. If they save it the last one wins, the other one’s changes are lost.

I would recommend some sort of file locking if an eaf file is opened. To make these locks as portable as possible I would only use a simple mechanism like the creation of a file, something like “.originalfilename.eaf.lock” (which may contain date, hostname and username of the lock holder). If somebody tries to open an already locked file, ELAN could simply display the content of the lock file.

What do you think?

Thanks,

Christopher

July 10, 2018 at 09:58 #12322

Han

Yes, this issue has been raised by other users as well recently, so we added it to the to do list.
I don’t know yet what the actual implementation would look like, but if possible I would prefer the use of a built-in Java file locking mechanism, but I didn’t really look into that yet.

-Han

July 10, 2018 at 11:40 #12323

odenbach

I am no Java programmer, but a quick search brought me up with java.nio.channels.FileLock which is the preferred built-in Java file locking mechanism. But the problem with this mechanism is that it depends on the operating system’s native locking mechanism and often fails on network file systems.

As ELAN is platform independent the locking mechanism should also try as hard as possible to be it. If people use network file systems across operating system boundaries (we do) they will also want locking across file system boundaries (we do). So in my opinion the native Java locking mechanism is no option.

Christopher

August 15, 2018 at 12:55 #12361

cschenk

Hi,
I have implemented the locking mechanism described by @odenbach: If someone opens a eaf File a File called “.originalfilename.eaf.lock” will be created and populated with a time stamp, the username and the hostname of the computer. If now someone tires to open the same file the user will get an error message like “This file is since 15.08.2018 11:51:42 opened by cschenk on cschenks-computer”.

I have published the code on Github. You can lock at it here:
https://github.com/chschenk/ELAN/tree/feature-filelocking

You can view the changes i have made here:
https://github.com/chschenk/ELAN/pull/1/commits/75dead0e6bd43daf0904817516d9102b474d51cd

I would love to see this get included into Elan

What do you think?

Thanks,

Christopher

August 16, 2018 at 17:40 #12365

Han

Thanks Christopher,

I didn’t have time yet to look into this matter of file locking in general and I only had a quick look at your implementation, so far.

In general I’m not too enthusiastic about this lock file approach; it doesn’t prevent an .eaf file from being edited in another application and I guess the lock file won’t be deleted in case of a crash of ELAN.

More specifically to your implementation, it seems that the file is being locked in TrancriptionImpl and unlocked when the ELAN frame is closed. But TranscriptionImpl is loaded in e.g. many multiple file operations (e.g. statistics for multiple files), without being made visible, and I guess locking isn’t needed in those situations but also the lock file probably won’t be deleted in such situations (I didn’t test this).

A smaller problem is that we’re still bound to Java 1.6…

Thanks,
Han

August 24, 2018 at 08:53 #12380

odenbach

Hi,

this lock file approach is quite common – even the vi editor uses it. If you open a file with vi and try to open the same file on another host with vi you get a warning. But the lock file does not prevent you from opening the file in another editor. Microsoft Office also uses such a scheme.

Preventing files from being opened generally is rather difficult and needs support from the underlying operating system and file system. But as ELAN is platform independant this is not possible as locks must also be made platform independant.

So please have a closer look at this locking mechanism. I am convinced that this is the only way platform independant locking is possible at all.

Cheers,

Christopher (the first one)

September 25, 2018 at 15:36 #12399

cschenk

Hi,

i have ported my Patch for ELAN version 5.3
You can find it right here:
https://github.com/chschenk/ELAN/pull/3
Also i have changed the patch so that it runs with Java 1.6

I would like to hear what you think about this one.

Thanks,
Christopher

October 2, 2018 at 10:45 #12407

Han

Sorry for the delay, but I’ll have a look (but I’m afraid this will even take some more time…).

October 5, 2018 at 11:51 #12416

odenbach

Hi,

we had some feedback on our patch. It works well on Linux and Windows, but MacOS computers fail to open and initialize ELAN files correctly. Do you know of anything special about opening files on MacOS X?

Thanks,

Christopher

November 7, 2018 at 09:42 #12488

Ulrich

Hi,

we use this patch in our group on Mac`s and Windows and it works very well. Without the “locking mechanism” we lost a lot of data. Now it’s almost impossible to work on one file at the same time by accident. So, we don’t have trouble with losing data anymore. It is a big improvement for ELAN!!!

Viewing 10 posts - 1 through 10 (of 17 total)

You must be logged in to reply to this topic.