mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 15:10:23 +00:00
Fix storage not saving when exiting while saving
This commit is contained in:
parent
9d4c4fe97d
commit
9e95c6b5b4
1 changed files with 13 additions and 1 deletions
|
@ -17,6 +17,7 @@ import java.util.ArrayList;
|
|||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
@ -226,7 +227,18 @@ public class StandardStorage extends DataStorage {
|
|||
}
|
||||
|
||||
public void save(boolean dispose) {
|
||||
if (!busyIo.tryLock()) {
|
||||
try {
|
||||
// If another save operation is in progress, we have to wait on dispose
|
||||
// Otherwise the application may quit and kill the daemon thread that is performing the other save operation
|
||||
if (dispose && !busyIo.tryLock(1, TimeUnit.MINUTES)) {
|
||||
return;
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We don't need to wait on normal saves though
|
||||
if (!dispose && !busyIo.tryLock()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue