Skip to content

Commit

Permalink
Allow not having a records directory
Browse files Browse the repository at this point in the history
It's valid to not have records (i.e. an empty swift file), and Bazel won't create empty directories when downloading from a remote cache.

Signed-off-by: Brentley Jones <github@brentleyjones.com>
  • Loading branch information
brentleyjones committed Sep 7, 2022
1 parent ce19774 commit 987a428
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions index-import.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,10 @@ static bool remapIndex(const Remapper &remapper,
SmallString<256> outputRecordsDirectory;
path::append(outputRecordsDirectory, OutputIndexPath, "v5", "records");

bool recordsDirectoryExists = fs::exists(recordsDirectory);

if (not fs::is_directory(unitDirectory) ||
not fs::is_directory(recordsDirectory)) {
(recordsDirectoryExists && not fs::is_directory(recordsDirectory))) {
errs() << "error: invalid index store directory " << InputIndexPath << "\n";
return false;
}
Expand Down Expand Up @@ -432,8 +434,10 @@ static bool remapIndex(const Remapper &remapper,

// This batch clones records in the entire index. If we're importing
// individual ouput files we don't want this.
if (not cloneRecords(recordsDirectory, InputIndexPath, outputIndexPath)) {
success = false;
if (recordsDirectoryExists) {
if (not cloneRecords(recordsDirectory, InputIndexPath, outputIndexPath)) {
success = false;
}
}

// Process and map the entire index directory
Expand Down

0 comments on commit 987a428

Please sign in to comment.