mirror of
https://github.com/rclone/rclone.git
synced 2024-12-23 23:49:15 +01:00
crypt: Add --crypt-show-mapping to show encrypted file mapping
Fixes #1004
This commit is contained in:
parent
20c033b484
commit
390f3cf35b
@ -12,6 +12,12 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Globals
|
||||
var (
|
||||
// Flags
|
||||
cryptShowMapping = fs.BoolP("crypt-show-mapping", "", false, "For all files listed show how the names encrypt.")
|
||||
)
|
||||
|
||||
// Register with Fs
|
||||
func init() {
|
||||
fs.Register(&fs.RegInfo{
|
||||
@ -485,11 +491,14 @@ func (lo *ListOpts) Level() int {
|
||||
// Multiple goroutines can safely add objects concurrently.
|
||||
func (lo *ListOpts) Add(obj fs.Object) (abort bool) {
|
||||
remote := obj.Remote()
|
||||
_, err := lo.f.cipher.DecryptFileName(remote)
|
||||
decryptedRemote, err := lo.f.cipher.DecryptFileName(remote)
|
||||
if err != nil {
|
||||
fs.Debug(remote, "Skipping undecryptable file name: %v", err)
|
||||
return lo.ListOpts.IsFinished()
|
||||
}
|
||||
if *cryptShowMapping {
|
||||
fs.Log(decryptedRemote, "Encrypts to %q", remote)
|
||||
}
|
||||
return lo.ListOpts.Add(lo.f.newObject(obj))
|
||||
}
|
||||
|
||||
@ -498,11 +507,14 @@ func (lo *ListOpts) Add(obj fs.Object) (abort bool) {
|
||||
// Multiple goroutines can safely add objects concurrently.
|
||||
func (lo *ListOpts) AddDir(dir *fs.Dir) (abort bool) {
|
||||
remote := dir.Name
|
||||
_, err := lo.f.cipher.DecryptDirName(remote)
|
||||
decryptedRemote, err := lo.f.cipher.DecryptDirName(remote)
|
||||
if err != nil {
|
||||
fs.Debug(remote, "Skipping undecryptable dir name: %v", err)
|
||||
return lo.ListOpts.IsFinished()
|
||||
}
|
||||
if *cryptShowMapping {
|
||||
fs.Log(decryptedRemote, "Encrypts to %q", remote)
|
||||
}
|
||||
return lo.ListOpts.AddDir(lo.f.newDir(dir))
|
||||
}
|
||||
|
||||
|
@ -236,6 +236,21 @@ depends on that.
|
||||
Hashes are not stored for crypt. However the data integrity is
|
||||
protected by an extremely strong crypto authenticator.
|
||||
|
||||
### Specific options ###
|
||||
|
||||
Here are the command line options specific to this cloud storage
|
||||
system.
|
||||
|
||||
#### --crypt-show-mapping ####
|
||||
|
||||
If this flag is set then for each file that the remote is asked to
|
||||
list, it will log (at level INFO) a line stating the decrypted file
|
||||
name and the encrypted file name.
|
||||
|
||||
This is so you can work out which encrypted names are which decrypted
|
||||
names just in case you need to do something with the encrypted file
|
||||
names, or for debugging purposes.
|
||||
|
||||
## File formats ##
|
||||
|
||||
### File encryption ###
|
||||
|
Loading…
Reference in New Issue
Block a user