Package me.desair.tus.server.upload.disk
Class FileBasedLock
java.lang.Object
me.desair.tus.server.upload.disk.FileBasedLock
- All Implemented Interfaces:
AutoCloseable
,UploadLock
Upload locking implementation using the file system file locking mechanism. File locking can also
apply to shared network drives. This way the framework supports clustering as long as the upload
storage directory is mounted as a shared (network) drive.
File locks are also automatically released on application (JVM) shutdown. This means the file locking is not persistent and prevents cleanup and stale lock issues.
File locks are also automatically released on application (JVM) shutdown. This means the file locking is not persistent and prevents cleanup and stale lock issues.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected FileChannel
Get the upload URI of the upload that is locked by this lockvoid
release()
Method to release the lock on an upload when done processing it.
-
Field Details
-
lockPath
-
-
Constructor Details
-
FileBasedLock
public FileBasedLock(String uploadUri, Path lockPath) throws UploadAlreadyLockedException, IOException
-
-
Method Details
-
getUploadUri
Description copied from interface:UploadLock
Get the upload URI of the upload that is locked by this lock- Specified by:
getUploadUri
in interfaceUploadLock
- Returns:
- The URI of the locked upload
-
release
public void release()Description copied from interface:UploadLock
Method to release the lock on an upload when done processing it. It's possible that this method is called multiple times within the same request- Specified by:
release
in interfaceUploadLock
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceUploadLock
- Throws:
IOException
-
createFileChannel
- Throws:
IOException
-