Skip to content

Commit e1f11ab

Browse files
committed
Add RecordNode disk space check
1 parent 0dead8a commit e1f11ab

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

Source/Processors/RecordNode/RecordNode.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,31 @@ RecordNode::RecordNode()
7575

7676
eventMonitor = new EventMonitor();
7777

78+
checkDiskSpace();
79+
7880
}
7981

8082
RecordNode::~RecordNode()
8183
{
8284
}
8385

86+
void RecordNode::checkDiskSpace()
87+
{
88+
int diskSpaceWarningThreshold = 5; //GB
89+
90+
File dataDir(dataDirectory);
91+
int64 freeSpace = dataDir.getBytesFreeOnVolume();
92+
93+
float avaialableBytes = freeSpace / pow(2, 30); //1 GB == 2^30 bytes
94+
95+
if (avaialableBytes < diskSpaceWarningThreshold)
96+
{
97+
String msg = "Less than " + String(diskSpaceWarningThreshold) + " GB of disk space available in " + String(dataDirectory.getFullPathName());
98+
msg += ". Recording may fail. Please free up space or change the recording directory.";
99+
AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon, "WARNING", msg);
100+
}
101+
}
102+
84103

85104
String RecordNode::handleConfigMessage(String msg)
86105
{
@@ -192,6 +211,8 @@ void RecordNode::setDataDirectory(File directory)
192211
{
193212
dataDirectory = directory;
194213
newDirectoryNeeded = true;
214+
215+
checkDiskSpace();
195216
}
196217

197218
void RecordNode::createNewDirectory()

Source/Processors/RecordNode/RecordNode.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ class RecordNode :
160160
/** Returns the parent directory for this Record Node (can be different from default directory) */
161161
File getDataDirectory();
162162

163+
/** Checks if the current recording directory has sufficient space to record */
164+
void checkDiskSpace();
165+
163166
/** Returns true if this Record Node is writing data*/
164167
bool getRecordingStatus() const;
165168

0 commit comments

Comments
 (0)