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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected FileChannelGet the upload URI of the upload that is locked by this lockvoidrelease()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:UploadLockGet the upload URI of the upload that is locked by this lock- Specified by:
getUploadUriin interfaceUploadLock- Returns:
- The URI of the locked upload
-
release
public void release()Description copied from interface:UploadLockMethod 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:
releasein interfaceUploadLock
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceUploadLock- Throws:
IOException
-
createFileChannel
- Throws:
IOException
-