|
@@ -44,9 +44,6 @@ import java.util.Optional;
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
-import java.util.concurrent.locks.Condition;
|
|
|
|
-import java.util.concurrent.locks.Lock;
|
|
|
|
-import java.util.concurrent.locks.ReentrantLock;
|
|
|
|
|
|
|
|
import static org.cryptomator.common.Constants.MASTERKEY_FILENAME;
|
|
import static org.cryptomator.common.Constants.MASTERKEY_FILENAME;
|
|
|
|
|
|
@@ -74,8 +71,6 @@ public class Vault {
|
|
private final StringBinding accessPoint;
|
|
private final StringBinding accessPoint;
|
|
private final BooleanBinding accessPointPresent;
|
|
private final BooleanBinding accessPointPresent;
|
|
private final BooleanProperty showingStats;
|
|
private final BooleanProperty showingStats;
|
|
- private final Lock lock = new ReentrantLock(); //FIXME: naming
|
|
|
|
- private final Condition isLocked = lock.newCondition(); //FIXME: improve naming
|
|
|
|
|
|
|
|
private volatile Volume volume;
|
|
private volatile Volume volume;
|
|
|
|
|
|
@@ -152,13 +147,6 @@ public class Vault {
|
|
if (throwable != null) {
|
|
if (throwable != null) {
|
|
LOG.warn("Unexpected unmount and lock of vault " + getDisplayName(), throwable);
|
|
LOG.warn("Unexpected unmount and lock of vault " + getDisplayName(), throwable);
|
|
}
|
|
}
|
|
- lock.lock();
|
|
|
|
- try {
|
|
|
|
- isLocked.signal();
|
|
|
|
- } finally {
|
|
|
|
- lock.unlock();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
});
|
|
});
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
destroyCryptoFileSystem();
|
|
destroyCryptoFileSystem();
|
|
@@ -176,20 +164,15 @@ public class Vault {
|
|
volume.unmount();
|
|
volume.unmount();
|
|
}
|
|
}
|
|
destroyCryptoFileSystem();
|
|
destroyCryptoFileSystem();
|
|
- lock.lock();
|
|
|
|
try {
|
|
try {
|
|
- while (state.get() != VaultState.Value.LOCKED) {
|
|
|
|
- if (!isLocked.await(3000, TimeUnit.MILLISECONDS)) {
|
|
|
|
- throw new VolumeException("Locking failed"); //FIXME: other exception
|
|
|
|
- }
|
|
|
|
|
|
+ boolean locked = state.awaitState(VaultState.Value.LOCKED, 3000, TimeUnit.MILLISECONDS);
|
|
|
|
+ if (!locked) {
|
|
|
|
+ throw new VolumeException("Locking failed"); //FIXME: other exception
|
|
}
|
|
}
|
|
} catch (InterruptedException e) {
|
|
} catch (InterruptedException e) {
|
|
Thread.currentThread().interrupt();
|
|
Thread.currentThread().interrupt();
|
|
throw new VolumeException("Lock failed."); //FIXME: other/new exception
|
|
throw new VolumeException("Lock failed."); //FIXME: other/new exception
|
|
- } finally {
|
|
|
|
- lock.unlock();
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public void reveal(Volume.Revealer vaultRevealer) throws VolumeException {
|
|
public void reveal(Volume.Revealer vaultRevealer) throws VolumeException {
|