mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-14 18:02:31 +08:00
Merge pull request #6722 from sfc-gh-satherton/fix-backup-backward-compatibility
Fixed Codec<Reference<IBackupContainer>> backward compatibility bug from #6705
This commit is contained in:
commit
e2c66de28f
@ -727,30 +727,36 @@ template <>
|
||||
inline Tuple Codec<Reference<IBackupContainer>>::pack(Reference<IBackupContainer> const& bc) {
|
||||
Tuple tuple;
|
||||
tuple.append(StringRef(bc->getURL()));
|
||||
if (bc->getProxy().present()) {
|
||||
tuple.append(StringRef(bc->getProxy().get()));
|
||||
} else {
|
||||
tuple.append(StringRef());
|
||||
}
|
||||
|
||||
if (bc->getEncryptionKeyFileName().present()) {
|
||||
tuple.append(bc->getEncryptionKeyFileName().get());
|
||||
} else {
|
||||
tuple.append(StringRef());
|
||||
}
|
||||
|
||||
if (bc->getProxy().present()) {
|
||||
tuple.append(StringRef(bc->getProxy().get()));
|
||||
} else {
|
||||
tuple.append(StringRef());
|
||||
}
|
||||
|
||||
return tuple;
|
||||
}
|
||||
template <>
|
||||
inline Reference<IBackupContainer> Codec<Reference<IBackupContainer>>::unpack(Tuple const& val) {
|
||||
ASSERT(val.size() == 3);
|
||||
ASSERT(val.size() >= 1);
|
||||
auto url = val.getString(0).toString();
|
||||
Optional<std::string> proxy;
|
||||
if (!val.getString(1).empty()) {
|
||||
proxy = val.getString(1).toString();
|
||||
}
|
||||
|
||||
Optional<std::string> encryptionKeyFileName;
|
||||
if (!val.getString(2).empty()) {
|
||||
encryptionKeyFileName = val.getString(2).toString();
|
||||
if (val.size() > 1 && !val.getString(1).empty()) {
|
||||
encryptionKeyFileName = val.getString(1).toString();
|
||||
}
|
||||
|
||||
Optional<std::string> proxy;
|
||||
if (val.size() > 2 && !val.getString(2).empty()) {
|
||||
proxy = val.getString(2).toString();
|
||||
}
|
||||
|
||||
return IBackupContainer::openContainer(url, proxy, encryptionKeyFileName);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user