vsajip/python-gnupg

Support direct file input

sebbASF opened this issue · 5 comments

At present the commands such as key import and file verify rely on copying the data to a temporary file.
This seems very inefficient.
Surely the file name could just be passed to the gpg application?

Possibly, but in general the way it works now is "fast enough" for most applications. At least, no one has brought any performance problems to my attention.

It's not just speed / unnecessary resource usage.
It also relies on the client code to open/read the file with the correct options.
That should not be the concern of the client.

It may require new APIs to support paths in the API while preserving backward-compatibility. What would the API signatures be for the affected APIs, in your view?

I think the APIs could remain the same in most cases.
If it is a string, process it as a file name. Possibly check for file existence.
Otherwise assume it is a file-type object.

This should work for verify_file, encrypt_file, decrypt_file, get_recipients_file.
import_keys would need a corresponding import_keys_file.
[scan_keys already expects a filename]

Should be fixed in 334b90d.