From e4575f33bec7d1b34d2005c91657bb2c503144cd Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Thu, 13 Jun 2019 08:50:40 -0700 Subject: [PATCH] Migrate to optional_field_ref Thrift API Summary: Migrate the code from accessing optional Thrift fields directly to a safer `optional_field_ref` API. See https://fburl.com/safe for more details. The output of this codemod has been reviewed in D13259011. To preserve semantics, each unchecked access is replaced with an explicit call to `value_unchecked()`. If you are sure that accessing a field is safe (the field is marked as set), you can later replace `value_unchecked()` with `value()` or dereferencing (`operator *`): ``` ThriftStruct s = ... - auto foo = s.foo_ref().value_unchecked(); + auto foo = *s.foo_ref(); // will throw if s.foo is unset ``` drop-conflicts Reviewed By: stevegury Differential Revision: D15786632 fbshipit-source-id: 7c3f089dfa79597b189da6996cb76dcdbd5ed612 --- eden/fs/store/mononoke/MononokeThriftBackingStore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eden/fs/store/mononoke/MononokeThriftBackingStore.cpp b/eden/fs/store/mononoke/MononokeThriftBackingStore.cpp index e163377a6e..d89106cff6 100644 --- a/eden/fs/store/mononoke/MononokeThriftBackingStore.cpp +++ b/eden/fs/store/mononoke/MononokeThriftBackingStore.cpp @@ -97,7 +97,7 @@ folly::Future> MononokeThriftBackingStore::getTree( Hash(file.hash.hash), file.name, treeEntryTypeFromMononoke(file.file_type), - file.size, + file.size_ref().value_unchecked(), Hash(file.content_sha1_ref().value_unchecked())); } else { entries.emplace_back(