Questions tagged [filelock]

File locks are locks held by an application, preventing interference from other processes. Locks may be advisory (may be ignored by others), or mandatory, enforced by the operating system, depending on implementation.

File locks are locks held by an application, preventing interference from other processes. Locks may be advisory (may be ignored by others), or mandatory, enforced by the operating system, depending on implementation.

190 questions
9
votes
6 answers

how to best wait for a filelock to release

I have an application where i sometimes need to read from file being written to and as a result being locked. As I have understood from other questions i should catch the IOException and retry until i can read. But my question is how do i know for…
Tjelle
  • 986
  • 1
  • 9
  • 17
9
votes
3 answers

In Java, Is there a way to read a file when that file is locked by other thread?

So i used the following to create a lock on a file so that I can edit it exclusively: File file = new File(filename); channel = new RandomAccessFile(file, "rw").getChannel(); lock = channel.tryLock(); Now I have a 2nd thread want to access the…
neo
  • 2,461
  • 9
  • 42
  • 67
9
votes
2 answers

How do I get WPF's DocumentViewer to release its file lock on the source XPS Document?

After showing an XPS file in the WPF DocumentViewer, and closing the DocumentViewer instance, the XPS file is locked and I cannot delete it. I need to release the lock on the XPS file so I can delete it, write another one with the same name, and…
Tim Erickson
  • 2,323
  • 2
  • 22
  • 27
8
votes
1 answer

Random access file FileLock: java.io vs. java.nio

I've noticed that java.io and java.nio implementations of random access files differ slightly with respect to how FileLocks are handled. It appears as though (on Windows) java.io gives you a mandatory file lock and java.nio gives you an advisory…
predi
  • 5,528
  • 32
  • 60
8
votes
1 answer

What is Apache Camel's File "camelLock"?

Whenever I start a Camel route from a file URI, I see that Camel obtains a "lock" on the file. For instance, if the file is named myinput.xml, then Camel creates a "lock file" on it, in the same directory, called myinput.xml.camelLock. What is this…
AdjustingForInflation
  • 1,571
  • 2
  • 26
  • 50
7
votes
1 answer

Why does the Python filelock library delete lockfiles on Windows but not UNIX?

I'm using the filelock module for Python. On Windows, when a lock is released, the file that's backing it is deleted. On UNIX, lock files still exist on the filesystem even after the locks are released. Is there a reason this is different between…
7
votes
2 answers

Is it safe to use flock on AWS EFS to emulate a critical section?

According to the docs, AWS EFS (Amazon Elastic File System) supports file locking: Amazon EFS provides a file system interface and file system access semantics (such as strong data consistency and file locking). On a local file system (e.g.,…
Philipp Claßen
  • 41,306
  • 31
  • 146
  • 239
7
votes
1 answer

Mediawiki error: File upload not working

I've installed Mediawiki v1.24.1 on my server which is running RHEL7. I've installed it under /var/www/foohelp/wiki. However, when I try to upload a file, I get the following error: [f3eae72a] /foohelp/wiki/index.php/Special:Upload Exception from…
7
votes
1 answer

Problem with Java file locking mechanism (FileLock etc)

I am creating a simple application for opening and editing xml files. These files are located in a local folder accessed by multiple instances of the application. What I want to do is lock each file that is opened by an instance of the app, so that…
KostasT
  • 71
  • 1
  • 2
7
votes
2 answers

Java file locking and Windows - the lock isn't "absolute"?

I'm trying to lock a file with Java in Windows environment with FileLock and I got an issue : after I lock the file it can still be accessed by other processes at least on some level. Example code follows: public class SimpleLockExample { public…
Touko
  • 11,359
  • 16
  • 75
  • 105
6
votes
1 answer

.NET PrivateFontCollection - how to release file locks when finished

I have a function which returns a PrivateFontCollection: Public Shared Function GetCustomFonts() As PrivateFontCollection Dim result = New PrivateFontCollection Dim customFontFiles = {"Garamond.TTF", "Garamond-Bold.TTF",…
extremeandy
  • 503
  • 3
  • 13
6
votes
1 answer

How can I release locks on files/folders after using Directory.GetFiles?

I'm using IO.Directory.GetFiles to search for files in a folder. After the searching is done, I can't use files in this folder until my application is closed. I haven't found any Dispose functions in DirectoryInfo class, so my question is: How can I…
user3561694
  • 105
  • 1
  • 9
5
votes
1 answer

Should I have a lock on a file when I want to delete it?

I have a bunch of files on a local file system. My server will serve those files. In some cases the server will receive an instruction to delete a file. At the moment I'm using FileChannel.lock() to acquire a lock on the file, this is mostly to…
mal
  • 3,022
  • 5
  • 32
  • 62
5
votes
2 answers

Opening a file output stream on a file that is already locked overwrites it

I came across this scenario and did not understand why it is happening. Can someone please help me understand the behaviour of nio file lock. I opened a file using FileOutputStream and after acquiring an exclusive lock using nio FileLock I wrote…
Archana
  • 53
  • 1
  • 4
5
votes
3 answers

How to synchronize file access in a Java servlet?

I created a small Java servlet for a simple purpose: Once it is called, it will do the following steps: Read file foo.json from the local filesystem Process the data from the file and do some changes to it Write back the changes to the…
Timo Ernst
  • 15,243
  • 23
  • 104
  • 165
1
2
3
12 13