Skip to content

Commit

Permalink
Fix bug when writing corpus file in the first time.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 725760961
  • Loading branch information
lszekeres authored and copybara-github committed Feb 11, 2025
1 parent 58dda9b commit 4b18e02
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions centipede/centipede.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ void Centipede::CorpusToFiles(const Environment &env, std::string_view dir) {
}

void Centipede::CorpusFromFiles(const Environment &env, std::string_view dir) {
WorkDir wd{env};
// Shard the file paths in `dir` based on hashes of filenames.
// Shard the file paths in the source `dir` based on hashes of filenames.
// Such partition is stable: a given file always goes to a specific shard.
std::vector<std::vector<std::string>> sharded_paths(env.total_shards);
std::vector<std::string> paths;
Expand All @@ -160,7 +159,14 @@ void Centipede::CorpusFromFiles(const Environment &env, std::string_view dir) {
sharded_paths[filename_hash % env.total_shards].push_back(path);
++total_paths;
}
// Iterate over all shards.

// If the destination `workdir` is specified (note that empty means "use the
// current directory"), we might need to create it.
if (!env.workdir.empty()) {
CHECK_OK(RemoteMkdir(env.workdir));
}

// Iterate over all shards, adding inputs to the current shard.
size_t inputs_added = 0;
size_t inputs_ignored = 0;
const auto corpus_file_paths = WorkDir{env}.CorpusFilePaths();
Expand Down

0 comments on commit 4b18e02

Please sign in to comment.