Class VimSwapFile
java.lang.Object
io.goobi.viewer.model.administration.configeditor.VimSwapFile
Utility für vim-kompatible Swap-Dateien (B0-Block-Format).
pid==0 im B0-Block ist der Web-UI-Marker. Vim schreibt immer eine echte PID.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic VimSwapFile.StatusChecks the lock status offileby inspecting its swap file.static voidCreates a vim-compatible B0-block swap file forfile, usingpid=0as the Web-UI marker.static voidCreates a vim-compatible B0-block swap file withpid=0(web-UI marker), tagged with an owner token so that only the owning session deletes it again.static voidDeletes the Web-UI swap file forfileif it exists and is owned by the Web UI (pid=0).static voidDeletes the web-UI swap file forfileonly if it is owned by the web UI (pid=0) AND its owner tag matchessessionId.static PathgetSwapFilePath(Path file) Returns the path of the vim-style swap file for the given file.
-
Method Details
-
getSwapFilePath
Returns the path of the vim-style swap file for the given file. The swap file is named.<filename>.swpand located in the same directory asfile.- Parameters:
file- the file to lock- Returns:
- the swap file path
-
create
Creates a vim-compatible B0-block swap file forfile, usingpid=0as the Web-UI marker. Vim will recognise the swap file and warn any user who tries to open the file concurrently.- Parameters:
file- the file to lockhostname- the hostname to embed in the swap file; ifnull, the local hostname is used- Throws:
IOException- if the swap file cannot be written
-
create
Creates a vim-compatible B0-block swap file withpid=0(web-UI marker), tagged with an owner token so that only the owning session deletes it again.- Parameters:
file- the file to lockhostname- hostname to embed; ifnull, the local hostname is usedsessionId- owning HTTP session id (tagged as a hash); may benullfor an untagged swap file- Throws:
IOException- if the swap file cannot be written
-
delete
Deletes the Web-UI swap file forfileif it exists and is owned by the Web UI (pid=0). Swap files owned by a running vim process (non-zero pid) are never deleted. If the swap file cannot be read, a warning is logged and no deletion is attempted.- Parameters:
file- the file whose swap file should be removed
-
delete
Deletes the web-UI swap file forfileonly if it is owned by the web UI (pid=0) AND its owner tag matchessessionId. A swap file owned by a running vim process or by a different session is left.- Parameters:
file- the file whose swap file should be removedsessionId- the session that must own the swap file
-
check
Checks the lock status offileby inspecting its swap file.VimSwapFile.Status.NONE– no swap file existsVimSwapFile.Status.LOCKED_BY_WEBUI– swap file present withpid=0(Web-UI lock)VimSwapFile.Status.LOCKED_BY_VIM– swap file owned by an active vim process, or unreadable/truncatedVimSwapFile.Status.STALE_VIM– swap file owned by a non-zero pid that no longer exists in/proc
/procis unavailable, a non-zero pid is conservatively reported asVimSwapFile.Status.LOCKED_BY_VIM.- Parameters:
file- the file to check- Returns:
- the lock status
-