geforkt von Mirrors/FastAsyncWorldEdit
feat: add config option for if the DOC should lock the file channel (#2526)
- related to #2222 - effectively just a workaround as most people would not need to worry about locking the clipboard file
Dieser Commit ist enthalten in:
Ursprung
f44b1b48c7
Commit
6caf4640ea
@ -721,6 +721,13 @@ public class Settings extends Config {
|
|||||||
" - Requires clipboard.use-disk to be enabled"
|
" - Requires clipboard.use-disk to be enabled"
|
||||||
})
|
})
|
||||||
public boolean SAVE_CLIPBOARD_NBT_TO_DISK = true;
|
public boolean SAVE_CLIPBOARD_NBT_TO_DISK = true;
|
||||||
|
@Comment({
|
||||||
|
"Apply a file lock on the clipboard file (only relevant if clipboad.on-disk is enabled)",
|
||||||
|
" - Prevents other processes using the file whilst in use by FAWE",
|
||||||
|
" - This extends to other servers, useful if you have multiple servers using a unified clipboard folder",
|
||||||
|
" - May run into issues where a file lock is not correctly lifted"
|
||||||
|
})
|
||||||
|
public boolean LOCK_CLIPBOARD_FILE = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,6 +305,7 @@ public class DiskOptimizedClipboard extends LinearClipboard {
|
|||||||
private void init() throws IOException {
|
private void init() throws IOException {
|
||||||
if (this.fileChannel == null) {
|
if (this.fileChannel == null) {
|
||||||
this.fileChannel = braf.getChannel();
|
this.fileChannel = braf.getChannel();
|
||||||
|
if (Settings.settings().CLIPBOARD.LOCK_CLIPBOARD_FILE) {
|
||||||
try {
|
try {
|
||||||
FileLock lock = this.fileChannel.lock();
|
FileLock lock = this.fileChannel.lock();
|
||||||
LOCK_HOLDER_CACHE.put(file.getName(), new LockHolder(lock));
|
LOCK_HOLDER_CACHE.put(file.getName(), new LockHolder(lock));
|
||||||
@ -322,6 +323,7 @@ public class DiskOptimizedClipboard extends LinearClipboard {
|
|||||||
// Rethrow to prevent clipboard access
|
// Rethrow to prevent clipboard access
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.byteBuffer = fileChannel.map(FileChannel.MapMode.READ_WRITE, 0, braf.length());
|
this.byteBuffer = fileChannel.map(FileChannel.MapMode.READ_WRITE, 0, braf.length());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren