Skip to content

Commit

Permalink
fix: exporter should return err properly
Browse files Browse the repository at this point in the history
  • Loading branch information
saturneric committed Jul 29, 2024
1 parent 02bb9de commit a0a8c4b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/core/function/gpg/GpgKeyImportExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ auto GpgKeyImportExporter::ExportKey(const GpgKey& key, bool secret, bool ascii,
GpgData data_out;
auto* ctx = ascii ? ctx_.DefaultContext() : ctx_.BinaryContext();
auto err = gpgme_op_export_keys(ctx, keys_array.data(), mode, data_out);
if (gpgme_err_code(err) != GPG_ERR_NO_ERROR) return {};
if (gpgme_err_code(err) != GPG_ERR_NO_ERROR) return {err, {}};

return {err, data_out.Read2GFBuffer()};
}
Expand Down Expand Up @@ -122,7 +122,7 @@ void GpgKeyImportExporter::ExportKeys(const KeyArgsList& keys, bool secret,
GpgData data_out;
auto* ctx = ascii ? ctx_.DefaultContext() : ctx_.BinaryContext();
auto err = gpgme_op_export_keys(ctx, keys_array.data(), mode, data_out);
if (gpgme_err_code(err) != GPG_ERR_NO_ERROR) return {};
if (gpgme_err_code(err) != GPG_ERR_NO_ERROR) return err;

data_object->Swap({data_out.Read2GFBuffer()});
return err;
Expand Down Expand Up @@ -152,7 +152,7 @@ void GpgKeyImportExporter::ExportAllKeys(const KeyArgsList& keys, bool secret,
GpgData data_out;
auto* ctx = ascii ? ctx_.DefaultContext() : ctx_.BinaryContext();
auto err = gpgme_op_export_keys(ctx, keys_array.data(), mode, data_out);
if (gpgme_err_code(err) != GPG_ERR_NO_ERROR) return {};
if (gpgme_err_code(err) != GPG_ERR_NO_ERROR) return err;

auto buffer = data_out.Read2GFBuffer();

Expand All @@ -163,7 +163,7 @@ void GpgKeyImportExporter::ExportAllKeys(const KeyArgsList& keys, bool secret,
GpgData data_out_secret;
auto err = gpgme_op_export_keys(ctx, keys_array.data(), mode,
data_out_secret);
if (gpgme_err_code(err) != GPG_ERR_NO_ERROR) return {};
if (gpgme_err_code(err) != GPG_ERR_NO_ERROR) return err;

buffer.Append(data_out_secret.Read2GFBuffer());
}
Expand Down

0 comments on commit a0a8c4b

Please sign in to comment.