Skip to content

Commit

Permalink
Merge pull request #5275 from NREL/issue-5274-remove-zip-size-limits
Browse files Browse the repository at this point in the history
Fix #5274 - workflow should not remove contents from zip because of size limit
  • Loading branch information
jmarrec authored Oct 30, 2024
2 parents c8b9868 + d79e5f7 commit cae9435
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions src/workflow/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,17 +246,6 @@ void zipDirectory(const openstudio::path& dirPath, const openstudio::path& zipFi

static constexpr std::array<std::string_view, 3> filterOutDirNames{"seed", "measures", "weather"};

auto directorySize = [](const openstudio::path& dirPath) {
uintmax_t dirSize = 0;
for (const auto& dirEnt : fs::recursive_directory_iterator{dirPath}) {
const auto& dirEntryPath = dirEnt.path();
if (fs::is_regular_file(dirEntryPath)) {
dirSize += fs::file_size(dirEntryPath);
}
}
return dirSize;
};

for (const auto& dirEnt : fs::directory_iterator{dirPath}) {
const auto& dirEntryPath = dirEnt.path();
if (fs::is_directory(dirEntryPath)) {
Expand All @@ -266,23 +255,13 @@ void zipDirectory(const openstudio::path& dirPath, const openstudio::path& zipFi
continue;
}

auto dirSize = directorySize(dirEntryPath);
if (dirSize >= 15'000'000) {
LOG_FREE(Info, "openstudio.workflow.Util.zipDirectory", "Skipping too large directory " << dirEntryPath);
continue;
}

// TODO: do I need a helper like the workflow-gem was doing with add_directory_to_zip?
zf.addDirectory(dirEntryPath, fs::relative(dirEntryPath, dirPath));
} else {
auto ext = dirEntryPath.extension().string();
if ((ext.find(".zip") != std::string::npos) || (ext.find(".rb") != std::string::npos)) {
continue;
}

if ((ext != ".osm") && (ext != ".idf") && (fs::file_size(dirEntryPath) > 100'000'000)) {
continue;
}
zf.addFile(dirEntryPath, fs::relative(dirEntryPath, dirPath));
}
}
Expand Down

0 comments on commit cae9435

Please sign in to comment.