Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client: when computing disk usage, don't include VM shared directories #3901

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/filesys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,26 @@ int clean_out_dir(const char* dirpath) {
return 0;
}

// check whether the dir is probably the shared dir for a VM job.
// We don't want to count these in disk usage because the storage
// is inside the VM, so it's already been counted
//
static bool is_vm_shared_dir(const char* dirpath) {
if (!strstr(dirpath, "slots/")) return false;
const char* p = strstr(dirpath, "shared");
if (!p) return false;
return (p == dirpath + strlen(dirpath) - 6);
}

// return total size of files in directory and optionally its subdirectories
// Win: use special version because stat() is slow, can be avoided
// Unix: follow symbolic links
//
int dir_size(const char* dirpath, double& size, bool recurse) {
if (is_vm_shared_dir(dirpath)) {
size = 0;
return 0;
}
#ifdef WIN32
char buf[_MAX_PATH];
char path2[_MAX_PATH];
Expand Down Expand Up @@ -523,6 +538,10 @@ int dir_size(const char* dirpath, double& size, bool recurse) {
// Unix: follow symbolic links
//
int dir_size_alloc(const char* dirpath, double& size, bool recurse) {
if (is_vm_shared_dir(dirpath)) {
size = 0;
return 0;
}
#ifdef WIN32
char buf[_MAX_PATH];
char path2[_MAX_PATH];
Expand Down