Commit 9551fc21 authored by Ivan Čukić's avatar Ivan Čukić 👁

Mark the source directory as busy while Vault is mounted

In order to prevent accidental unmounting of a drive which
holds vault's encrypted data while the vault is open,
fopen the source directory.
parent a13da523
......@@ -62,6 +62,23 @@ public:
KSharedConfigPtr config;
Device device;
FILE* deviceDirectoryLock = nullptr;
void lockDeviceDirectory()
{
if (!deviceDirectoryLock) {
deviceDirectoryLock = fopen(device.data().toLocal8Bit().data(), "r");
}
}
void unlockDeviceDirectory()
{
if (deviceDirectoryLock) {
fclose(deviceDirectoryLock);
deviceDirectoryLock = nullptr;
}
}
QTimer savingDelay;
......@@ -207,6 +224,12 @@ public:
emit q->statusChanged(VaultInfo::Error);
}
if (data && data->status == VaultInfo::Opened) {
lockDeviceDirectory();
} else {
unlockDeviceDirectory();
}
}
......@@ -289,6 +312,13 @@ public:
~Private()
{
unlockDeviceDirectory();
}
template <typename T>
T followFuture(VaultInfo::Status whileNotFinished, const T &future)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment